2017-12-30 45 views
2

목표 : 양식 안의 아이콘을 클릭하면 양식이 들어있는 div에 새 클래스를 추가하고 싶습니다. 문제점 : 풀다운 메뉴에서 Jquery selector가 요소를 선택하지 않습니다. Console.log result of Jquery sector in this image. 요소가 가져 오지 않기 때문에 addAclass는 작동하지 않습니다. 내가하고있는 실수를 알아낼 수 있습니까? 사전에 감사Jquery Selector가 Polymer에서 div 요소를 찾을 수 없습니다. 직접 이해해야합니다. 이슈를 이해하지 못했습니다.

HTML

<div class="sidepullup" id="idSidePullup"> 
      <iron-icon class="cross" on-click="pullupClose" icon="close"></iron-icon> 
      <iron-form id="idForm"> 
       <form action="/"> 
        <paper-input type"text" label="First Name"></paper-input> 
        <paper-input type="text" label="Last Name"></paper-input> 
        <paper-input type="text" label="Title"></paper-input> 
        <paper-input type="text" label="About"></paper-input> 
        <paper-button style="background-color: #03a9f4; color: white" raised onclick="onFormSubmit()">Submit Changes</paper-button> 
       </form> 
      </iron-form> 
     </div> 

스크립트

<script> 
     class IronListClass extends Polymer.Element { 
      static get is() {return 'iron-comp'} 
     ready() { 
       super.ready(); 
       var that = this; 
      } 
      pullupClose() { 
       var element = $("#idSidePullup"); 
       console.log('console log of $("#idSidePullup") = ', element); 
       $("#idSidePullup").addClass('hidePullup'); 
       $("#idSidePullup").css("display", "none"); 
      } 
window.customElements.define(IronListClass.is, IronListClass); 
    </script> 

답변

1

내가 먼저 폴리머 DOM을 대상으로해야합니다 생각합니다.

var element = $(Polymer.dom(this.root).querySelector('#idSidePullup')) 
+0

의견을 보내 주셔서 감사합니다. 시도하고 알려 드리겠습니다. –

+0

고마워요. 그것은 일했다!! Polymer에서 당신이하는 방식인지는 몰랐습니다. 이제 닫을 수 있습니다 :) –

+0

문제가 없으면 완료로 대답하십시오. :) – magreenberg