jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox Can Someone Explain…

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 10 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Can Someone Explain… #67227

    GrantM
    Participant

    The following code is meant to show an alert for each combo, each time the window is opened, but the order of events doesnt make alot of sense to me.

    Code: http://jsfiddle.net/wt5pahdc/4/

    1. Why does it not show the alert the first time you open it?
    2. Why does it not check each combo in order (1 – 2 – 3) every time? The order appears to change randomly.
    3. Why is it for each time you open and close the window, it checks each combo box an additional time?

    I have stripped alot of the original code but this is used to check the value of the combo in order to show or hide a button depending on the value. It should set the value of the combo (dynamic value) on the click event , then check that value. All done once for each combo and each time the window is opened.

    Thanks for your time.

    Can Someone Explain… #67238

    Peter Stoev
    Keymaster

    Hi GrantM,

    Short answer is: because the code is wrong.
    Long answer is: Bind to events 1 time if you want your callbacks to be called 1 time when action occurs. Example: http://jsfiddle.net/eew47gut/

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Can Someone Explain… #67248

    GrantM
    Participant

    Thanks Peter.

    The issue that now arrises is that i am loading the values for the combos dynamically using AJAX get and sometimes when i open the window, change the selected item on a combo, close the window then open again, it doesnt recognise that a new item has been selected and doesnt show the alert. I noticed it shows alerts based on the previous windows options rather than the options that are visibly selected when the window is open.

    I originally tried to combat that by setting the selected index (which it did) as you can see my first post, but then that is duplicating the bind event. Is the problem because my get get is asynchronous?

    where it has

    
                $("#combo1").jqxComboBox("selectItem", "Breve");
                $("#combo2").jqxComboBox("selectItem", "Café Bombón");
                $("#combo3").jqxComboBox("selectItem", "Affogato");
    

    I have

    
    					$.get("includes/getDashModsJSON.asp", function(data) {
    							$("#combo1").jqxComboBox("selectItem", data[0].Page);
    							$("#combo2").jqxComboBox("selectItem", data[1].Page);
    							$("#combo3").jqxComboBox("selectItem", data[2].Page);
    						},
    						"json"
    					);
    
    Can Someone Explain… #67303

    Peter Stoev
    Keymaster

    Hi GrantM,

    If you select an item when there is such item, i.e when the ComboBox’s data is already loaded, not before that, you will never had an issue selecting a specific item. However, if you try to select something which does not exist, then it will not be selected.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.