this question had been modified match actual problem.
the original question mistakingly focused on iron-ajax, please see original problem below. question should have been:
please advice why child iron-ajax element not ready during 'ready' callback of my-component defined follows:
<dom-module id="my-component"> <template> <link rel="import" href="../../../bower_components/iron-ajax/iron-ajax.html"> <iron-ajax id="selectionloader" url="" method="get" handle-as="json" debounce-duration="300" last-response="{{ suggestedoptions }}" last-error="{{ lasterror }}" verbose=true > </iron-ajax> </template> </dom-module> <script> (function () { polymer({ : 'paper-select', ready : function() { console.log(this.$.selectionloader.generaterequest); // undefined } }) })() </script> original question
original title: 'webcomponentsready' fires before iron-ajax ready - polymer 1.0
i need assign values observed property of custom component internally uses iron-ajax disabled auto - need call .generaterequest on iron-ajax element. should happen when host page/component ready, in order fetch server defaults based on data in host component code.
selected array property on component observed this:
observers: [ '_selectedchanged(selected.splices)' // _selectedchanged calls .generaterequest ] the observer triggered by:
window.addeventlistener('webcomponentsready', function() { document.queryselector('paper-select').selected = [{id : 11855},{id : 11856}]; }); the problem webcomponentsready fires before .generaterequest available on iron-ajax. component initialized, _selectedchanged called, iron-ajax inside missing method , in fact other properties/methods well.
i've implemented "deferred" workaround using settimeout inside component , works charm it's not way. works if observer triggered time later after page load, e.g. user's typing. shows logic works, it's timing wrong.
what missing?
the real issue having html imports inside component's <template>. 'wrong' order of events makes sense iron-ajax not registered @ time when host calls 'ready' callback.
i've moved imports outside <dom-module> , works expected.
Comments
Post a Comment