jQuery UI Widgets Forums Lists ListBox selectItem doesn't fire the listbox change event the first time

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 6 years, 7 months ago.

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

  • jccramer
    Participant

    I have code that creates and populates a listbox and then initializes other controls. I would like to use the listbox change event to do that initialization based on the item selected. The problem that I’m having is that the change event isn’t fired the first time selectItem is called after the listbox has been created and populated. It does fire the change even when the code is called later with a different selected item. The code is fairly simple:

    $(‘#editFilter’).jqxWindow(‘open’); // open the dialog
    $(‘#efList’).jqxListBox(‘selectItem’, item.name); // listbox has already been created and populated

    // field selection change and force the first call
    $(‘#efList’).on(‘change’, { fldArr: fldArr }, function (e) {
    var index = e.args.index,
    type = e.data.fldArr[index].type,
    name = e.data.fldArr[index].name,
    vals;
    // change processing code follows…

    The inconsistency is the real problem. I would prefer that selectItem fires the change event all the time but I could live with suppressing the change event when the selectItem is called on subsequent passes (as long as the change event is fired when the selects an item in the listbox with a mouse click).

    I would appreciate any help.

    Thanks,
    jcc


    Hristo
    Participant

    Hello jccramer,

    We recommend to use events and methods from specific widget.
    If you would like to share more of Your code or explain us what is your goal.
    Please take a look this example: http://jsfiddle.net/txhi/uzz5acbk/
    The ‘change’ event looks fires normal when made whatever change on the ListBox but need to be attached this event before happen.
    This will not happen in the case also if previously selected element with selectedIndex property.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    • This reply was modified 6 years, 7 months ago by  Hristo.
    • This reply was modified 6 years, 7 months ago by  Hristo.

    jccramer
    Participant

    Hi Hristo,

    Thanks, I figured that out. All of life’s problems can be solved by a good night’s sleep and a long “thinking” shower. In my defense (admittedly it’s a weak defense but it’s the only one that I have), I inherited the code and didn’t write it.

    Thanks for the response,
    jcc


    Hristo
    Participant

    Hello jccramer,

    Writing if there is any changes.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    • This reply was modified 6 years, 7 months ago by  Hristo.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.