3

I am using a couple of MagicSuggest controls on my page, with the following code:

<div id="my_id1" class="magicsuggest"></div>
<div id="my_id2" class="magicsuggest"></div>

...

var ms = $('.magicsuggest').magicSuggest({});
$(ms).on('selectionchange', function(event, combo, selection){
    var id = combo.input[0].offsetParent.id;

    ...
});

I have found this quite cumbersome way to retrieve back the id of my <div>, but am wondering if there is more elegant way to do this?

Gad
  • 41,526
  • 13
  • 54
  • 78
Ze Jibe
  • 989
  • 2
  • 11
  • 29

1 Answers1

0

You are actually not trying to get the ID of the combobox but of its container.

How about this:

    var ms = $('.magicsuggest').magicSuggest({});
    $(ms).on('selectionchange', function(event, combo, selection){
        var id = combo.container[0].id;

        ...
    });
Gad
  • 41,526
  • 13
  • 54
  • 78