Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9076627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:09:37+00:00 2026-06-16T19:09:37+00:00

I use dojo 1.8.2 and here is my problem (I have seen this and

  • 0

I use dojo 1.8.2 and here is my problem (I have seen this and this question, but they eren’t helpful) :

My JS code receives from server some data in JSON format. With that, I dynamically create some options for dijit.form.select:

var select = registry.byId('zgloszenieDoFirmyEdycja');
for (var uzytkownik in dane.uzytkownicy){
    var idUzytkownika = dane.uzytkownicy[uzytkownik]['_id']['$oid'];
    var imie = dane.uzytkownicy[uzytkownik].imie;
    var nazwisko = dane.uzytkownicy[uzytkownik].nazwisko;
    var wybrany = (idUzytkownika == id);
    var opcja = {};

    opcja.label = imie + ' ' + nazwisko;
    opcja.value = idUzytkownika;
    opcja.selected = wybrany;

    console.log(wybrany);
    console.log(idUzytkownika + ' | ' + imie + ' ' + nazwisko);
    console.log(opcja);

    select.addOption(opcja);
    /*select.addOption({
        label: imie + ' ' + nazwisko,
        value: idUzytkownika,
        selected: wybrany
    });*/
}

This is my console output:

false
5077d2a1e4b0f5734a9850a1 | zero zero
Object { label="zero zero", value="5077d2a1e4b0f5734a9850a1", selected=false}
true
50c0776f096aa0e726d221a3 | raz raz
Object { label="raz raz", value="50c0776f096aa0e726d221a3", selected=true}
false
50d019c3096aa862c6898cdb | dwa dwa
Object { label="dwa dwa", value="50d019c3096aa862c6898cdb", selected=false}

But after the dijit.form.select is updated, the selected parameter gets somehow mixed up and is set to true not for the option that I set it for, but for the first one:

console.log(select);
...
Object[Object { label="zero zero", value="5077d2a1e4b0f5734a9850a1", selected=true},      
       Object { label="raz raz", value="50c0776f096aa0e726d221a3", selected=false}, 
       Object { label="dwa dwa", value="50d019c3096aa862c6898cdb", selected=false}
]
...

I don’t understand why it happens, any clues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:09:38+00:00Added an answer on June 16, 2026 at 7:09 pm

    Looking into the source code of dijit/form/_FormSelectWidget the issue is caused by the fact, that if no option is selected then the first option gets selected by default. By the time you add the first option this condition is met and the first option gets selected.

    Workaround: add all options at once as an array:

    var select = registry.byId("select1");
    
    option1 = { value: "o1", label: "option 1", selected: false };
    option2 = { value: "o2", label: "option 2", selected: true };
    
    select.addOption([option1, option2]); // add all options at once as an array
    

    See it in action: http://jsfiddle.net/phusick/BfTXC/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: <ul data-dojo-type=dojox.mobile.RoundRectList> <li data-dojo-type=dojox.mobile.ListItem data-dojo-props='moveTo:places_aroud_me_view,callback: set_placeTypeAroundMe_calback(park),transition:slide'>Park</li> <li data-dojo-type=dojox.mobile.ListItem data-dojo-props='moveTo:places_aroud_me_view,callback: set_placeTypeAroundMe_calback(art),transition:slide'>Art</li>
in my Zend Framework App i wanna use Dojo Form. I have problem with
So here's the problem. We have some big dojo forms created using Zend_Dojo_Form. The
I'm working on a project where i have to use dojo (i'm doing a
I use Dojo 1.3.1, essentially under FF3.5 for now. I have a dnd source
I have a problem with events on IE8 (dread!), using dojo toolkit 1.4.3 (can't
My question is: can we use dojo.xhrPost to post some Json data? More detail:
my web application is based on dojo 1.6.0. The problem that I have is
If I have a <div id=test></div> how do I use Dojo to add and
I plan to use dojo.query to get some elements by their name attribute from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.