feronovak
feronovak

Reputation: 2697

How to change for select change in ajax generated select list

I have <select id="someid"></select>

I then click something and jquery.ajax generates new div and attach .html(data) to #someid select. How do I check for change in select?

The reason why I am asking is that I start with empty selects and load them with data related to one record.

There are two selects, select1 and select2. I generate select1 just once and based on selected option from select1 then I generate select2. I need to track if select1 has not been changed and whether I need to regenerate select2. Currently it doesnt do anything $("#select1").change(alert('test')) starts immediately after running the page but wont do anything after another change. It just wont run.

Is this possible?

Thanks.

Upvotes: 1

Views: 1167

Answers (1)

Alex
Alex

Reputation: 9041

If ive read the question right, this is very easy using .change()

$('select#someid').live('change', function() {
  // you code
});

Upvotes: 1

Related Questions