BetRob
BetRob

Reputation: 251

Dynamically set value of Select Box in JQM 1.3.1

I have been trying to set the value of the Select box on button click... This works on Jquery Mobile 1.2 and not on Jquery Mobile 1.3.1 with jquery 1.9.1

I have a FIDDLE ---> http://jsfiddle.net/betrob/bzTP2/ You can change the Fiddle Extensions to Jquery Mobile 1.3.1 and Jquery Mobile 1.2 ....

$(document).on('click', 'button', function(){

$('#Sel option[value="Three"]').prop('selected', 'selected'); });

Could someone please explain what changes I should be making inorder to get this to work...

Thank you.

Upvotes: 0

Views: 320

Answers (1)

Phill Healey
Phill Healey

Reputation: 3180

It works with the latest version of JQuery.

http://jsfiddle.net/bzTP2/1/

$(document).on('click', 'button', function(){
  $('#Sel option[value="Three"]').prop('selected', 'selected');
});

I wasn't using JQM that far back but I do know a lot of events have changed and so it may be something to do with that. I do know .live() became .on(). So it may be that something went wrong with version 1.3.0b1, since that would only be a minor revision over say 1.3.0 and 1.3.1. You'll also notice that the version of JQM in use on your fiddle is actually a beta version, hence not a stable version.

Besides, it's always advisable to use the latest stable release.

Upvotes: 1

Related Questions