polymer - variable not change after ajax call -


file objs.json: {     "id": 1,     "name": "my obj",     "description": "my obj desc" }  

file my-element.html:

<polymer-element name="my-obj"> <template>     <core-ajax id="ajax" auto url="objs.json"             on-core-response="itemsloaded" handleas="json"></core-ajax>     <p>{{obj.name}}</p> </template> <script type="text/javascript">     polymer({         ready: function() {             this.$.ajax.addeventlistener("core-response", function(e) {                 this.obj= e.detail.response;             });         },         itemsloaded: function() {             console.log(this.$.ajax);//.response         }     });  </script> 

why {{obj.name}} not change!?!?!

try this

<polymer-element name="my-obj"> <template>      <core-ajax         id="ajax"         url="objs.json"        on-core-response="{{itemsloaded}}"         handleas="json"     ></core-ajax>      <p>{{obj.name}}</p>  </template> <script>     polymer({         ready: function() {             this.$.ajax.go();         },         itemsloaded: function(e) {             this.obj = e.detail.response;         }     }); </script> 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -