0

I have a third-party js function that dynamically adds/removes options to a SELECT element and I would like to perform an action whenever options are changed.

I tried attaching an 'onchange' event to the select but the event is triggered only when changing 'selection', not 'options'.

Any hint on how I can do that?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Don
  • 16,928
  • 12
  • 63
  • 101
  • What does that mean `only when changing 'selection', not 'options'.` – mplungjan Feb 10 '11 at 13:27
  • Does the third-party function provide a callback mechanism? Which plugin/function/whatever is ist? – Felix Kling Feb 10 '11 at 13:27
  • @mplungjan: I was too short... I mean that 'onchange' is called when I change the selected option (by clicking on id and choosing another option); it is not called when the list of available options is changed by script. – Don Feb 10 '11 at 15:14
  • @Felix Kling: I'm using Django FilteredSelectMultiple widget (see http://stackoverflow.com/questions/1698435/django-multi-select-widget) – Don Feb 10 '11 at 15:17
  • 1
    If you cannot attach an event to the adding, you will need to monitor the length of the select's options using setInterval for example – mplungjan Feb 10 '11 at 17:03

1 Answers1

0

you'll have to hack the 3rd party script to call your function when it adds/removes (or exchange the 3rd party script to a suitable jquery plugin).

Ian Wood
  • 6,515
  • 5
  • 34
  • 73
  • I actually can do that, but I was wandering if there was an event-driven solution. – Don Feb 10 '11 at 15:18