Page 1 of 1

Setting a Select selected value

Posted: Sun Jun 22, 2014 10:28 am
by Joe Bohen

I have a select which I am constructing the option values and wish to set the displayed option, in the past I have used Appery('select name').val('My option'); then refresh the select. This no longer works with jquery1.9 the select displays a blank value! How would I achieve this in Jquery1.9?

Regards,
Joe


Setting a Select selected value

Posted: Sun Jun 22, 2014 11:18 pm
by Yurii Orishchuk

Hi Joe.

Please use code below:

pre

//You have to change "mobileselectmenu_10" with your select component name.
var yourSelect = Appery("mobileselectmenu_10");
yourSelect.val("default");
yourSelect.selectmenu('refresh', true);

/pre

Regards.


Setting a Select selected value

Posted: Mon Jun 23, 2014 5:28 pm
by Joe Bohen

Hi Yurii, I have tried the code without success! I have shared the project to a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a, would you have a look, the 'Select' has the items added on the success event of of the JourneyList service.

I am also experiencing some unexpected behavior on the click event on the 'event_btn' click event where I am using comparison operators to check out which item is selected from the select, this is failing to find the correct selected value. Whilst the project is shared would you be able to look at this as well?

Regards,
Joe


Setting a Select selected value

Posted: Mon Jun 23, 2014 10:17 pm
by Yurii Orishchuk

Hi Joe,

I've checked your app. And saw following mistake in your code:

In following line of code you have some wrong character on the start of the value.

pre

dropDown&#46;append('<option value="?' + val + '"?' + text + '</option');

/pre

See details on the screen: http://prntscr.com/3vtkpn/direct

So to get your code work you need to delete this character from your code.

Use code below:

pre

dropDown&#46;append('<option value="' + val + '"?' + text + '</option');

/pre

Regards.


Setting a Select selected value

Posted: Tue Jun 24, 2014 7:24 am
by Joe Bohen

Hi Yurii, Yes thanks that is a zero width space character which caused no problems in jquery 1.8. Thanks for pointing this out.


Setting a Select selected value

Posted: Thu Nov 27, 2014 4:00 pm
by Josiel Denardi6690187

Where I put this code? Page Load, Page Show, where? Thank you.


Setting a Select selected value

Posted: Thu Nov 27, 2014 4:01 pm
by Josiel Denardi6690187

The code is:

var yourSelect = Appery("mobileselectmenu_10");
yourSelect.val("default");
yourSelect.selectmenu('refresh', true);


Setting a Select selected value

Posted: Fri Nov 28, 2014 1:25 am
by Yurii Orishchuk

Hi Josiel,

You can run this code when you need to set default value to your select component.

If you need do it on page show - use "page show" event handler.

Also, make sure you have option with "default" value.

Regards.