ember.js - Updating a property is not visible in the DOM -
i have following drop-downs:
{{view settingsapp.select2selectview id="country-id" contentbinding=currentcountries optionvaluepath="content.code" optionlabelpath="content.withflag" selectionbinding=selectedcountry prompt="select country ..."}} ... {{view settingsapp.select2selectview id="city-id" contentbinding=currentcities selectionbinding=selectedcity prompt="select city ..."}}
the bound properties defined in controller:
settingsapp.serviceseditcontroller = settingsapp.baseeditcontroller.extend(settingsapp.servicesmixin, { needs : ['servicesindex'], selectedcountry : null, selectedcity : null, currentcountries : null, currentcities : null, init : function () { this._super(); }, setupcontroller : function (entry) { this._super(entry); var locator = settingsapp.locators.getlocator(this.get('content.properties.locator')); var countrycode = locator.get('country'), city = locator.get('city'); this.set('currentcountries', settingsapp.countries.getcountries()); this.set('currentcities', settingsapp.locators.getcities(countrycode)); this.set('selectedcountry', settingsapp.countries.getcountry(countrycode)); this.set('selectedcity', city); // add observers now, once setup this.addobserver('selectedcountry', this.selectedcountrychanged); }, selectedcountrychanged: function () { var countrycode = this.get('selectedcountry.code'); var currentcities = settingsapp.locators.getcities(countrycode); var selectedcity = currentcities[0]; this.set('currentcities', currentcities); this.set('selectedcity', selectedcity); }, ... });
initial setup working fine, changing country selection not update city selection in drop-down, though observer (selectedcountrychanged
) called , this.set('selectedcity', selectedcity);
working expected (as seen in console logging). currentcities
set after observer runs, active (selected) value not correct (remains unchanged).
are there known issues programmatic update of bound properties, in case selectionbinding
?
my select2selectview
is:
settingsapp.select2selectview = ember.select.extend({ prompt: 'please select...', classnames: ['input-xlarge'], didinsertelement: function() { ember.run.scheduleonce('afterrender', this, 'processchildelements'); }, processchildelements: function() { this.$().select2({ // here configuration of // select2 component escapemarkup: function (m) { return m; } // not want escape markup since displaying html in results }); }, willdestroyelement: function () { this.$().select2('destroy'); } });
check whether selected city getting displayed removing select2(replacing normal select). if that's case, selectionbinding has propagated select2.
Comments
Post a Comment