windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Ember not updating query parameters when calling transitionToRoute() right after

Asked By: Anonymous

In my application, I have an overall controller that manages state for a portion of the application, called SimpleSearch.

Within SimpleSearch, I have multiple SimpleSearchOptions, that display a list of choices to a user.

A user can select an option, and that selection is an action that is called from the view, that bubbles up to the SimpleSearchOptionController:

App.SimpleSearchOptionController = Ember.ObjectController.extend({
//....
    select: function (option) {
        option.queryName = this.get('queryName');
        this.get('simpleSearch').setSelection(option);
        this.set('selectedOption', option);
        this.set('hasSelectedOption', true);
        this.send('transitionToNextOption');
    },
//....

This action calls this.get('simpleSearch').setSelection(option);, which registers the selection with the SimpleSearchController:

App.SimpleSearchController = Ember.ObjectController.extend({
//....
    setSelection: function (option) {
        this.set(option.queryName, option.value);
        this.get('selectedOptions').set(option.queryName, option.value);
        this.get('model').notifyPropertyChange('selectedOptions');
        this.checkIfAllOptionsSelected();
    },
//....

The important line in there is: this.set(option.queryName, option.value);.

After it registers the selection, it moves to the next option, and if there isn’t one, it skips to the results of the search. That is called from this.send('transitionToNextOption');

App.SimpleSearchOptionController = Ember.ObjectController.extend({
//....
    transitionToNextOption: function () {
        var nextOptionId = parseInt(this.get("id")) + 1;
        var numOfOptions = this.get('simpleSearch.numOfOptions');
        if (nextOptionId < numOfOptions) {
            this.transitionToRoute('simpleSearchOption', nextOptionId);
        }
        else {
            this.transitionToRoute('simpleSearchResults');
        }
    },
//....

In setSelection() above, the line this.set(option.queryName, option.value); is setting a query parameter’s value. This only works correctly, and the url gets updated accordingly for all options, when I’m not transitioning to a different route.

If I comment out the lines:

else {
    this.transitionToRoute('simpleSearchResults');
}

Setting the property (this.set(option.queryName, option.value);) actually has the side effect of Ember updating the query parameter in the URL, which is my intent. If I include that line, and transition to a different route after setting that variable, the query parameter is not updated.

I was stepping through Ember’s code, but I can’t quite follow how it handles this. It continues into _doTransition(), and I’ve noticed that the transition to the route ‘simpleSearchResults’ always happens before the queryParams are passed through.

How do I get Ember to update the query parameter before it transitions to ‘simpleSearchResults’?

Thank you for any and all help.


Solution

Answered By: Anonymous

I solved my issue by wrapping the transition in an Ember.run.next() function:

transitionToNextOption: function () {
    var nextOptionId = parseInt(this.get("id")) + 1;
    var numOfOptions = this.get('simpleSearch.numOfOptions');
    if (nextOptionId < numOfOptions) {
        this.transitionToRoute('simpleSearchOption', nextOptionId);
    }
    else {
        var self = this;
        Ember.run.next(function() { self.transitionToRoute('simpleSearchResults'); });
    }
},

I’m assuming, but have not verified, that Ember was queuing up the action to transition to ‘simpleSearchResults’, and handles the query parameters similarly. Perhaps the transition to a different route was somehow interrupting or overwriting the query parameter being written to the URL.

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort http://www.kadinescort.net Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort