user3214886
user3214886

Reputation:

Select change event not firing

First of all, I did research on web about my problem but could not find any solution, and that made me to ask the question once again.

I have a select which is registered with change event , so when i change it on browser event fires but when i try pro-grammatically it does not work.

Select:

<select name="symbol" id="symbol" class='input-xmini'>
    <option>-Choose Symbol-</option>
    <option value="Categories">Categories</option>
    <option value="UpcInfo">UPC</option>
    <option value="Transaction">Transaction</option>
    <option value="Ticket">Ticket</option>
</select>

Event Registration:

$('#symbol').on('change',function(){    
    alert('changing symbol')
});

What i tried already:

  1. $('#symbol').val('Categories').trigger('change')
  2. $('#symbol').val('Categories').change()
  3. registered event handler inside document.ready function and also inside script tag itself.
  4. $(document).on('change','#symbol',function(){}

I need to change it pro-grammatically but this is not working.

Please people dont think i am just another noob who is asking question already asked multiple times.Help. Thanks.

NOTE: I have tried almost everything but it does not work , can someone tell me theoretically why this would not work?

Upvotes: 2

Views: 2342

Answers (2)

Anup
Anup

Reputation: 9738

Your Js may be conflicting, so try this :-

<script>
    var jq = jQuery.noConflict();
    jq(function(){
       jq('#symbol').on('change',function(){    
       alert('changing symbol');
    });
});
</script>

Upvotes: 0

Pesulap
Pesulap

Reputation: 894

I did this over on the function

$("body").on("change","#symbol",function(){
   alert('changing symbol')
})

http://jsfiddle.net/pTq2X/

Upvotes: 2

Related Questions