Ray Phelan
Posts: 0
Joined: Fri Apr 18, 2014 3:59 pm

Setting Toggle Switch with Javascript

Hi.

I am trying to set the value of a toggle switch with javascript.
It does not work.

I'm using this:

My toggle switch is called "toggle_switch"

On "Page Show"
Apperyio('toggle_switch').val('on');
Apperyio('toggle_switch').slider( "refresh" );

Does not work

I placed a button on the screen to test it with the same code "On Click"
Also does not work.

The tutorials are not correct in the Docs. Some of the do not work.

How do I do this?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Setting Toggle Switch with Javascript

Hello!

Please take a look here http://api.jquerymobile.com/flipswitc...
You need the following code preApperyio("tog").val("off");
Apperyio("tog").flipswitch("refresh");/pre

Ray Phelan
Posts: 0
Joined: Fri Apr 18, 2014 3:59 pm

Setting Toggle Switch with Javascript

Thank you Maryna! :)

ewan
Posts: 0
Joined: Wed Jun 04, 2014 3:41 pm

Setting Toggle Switch with Javascript

hi,

Nice solution. One comment:
http://devcenter.appery.io/documentat...

appears to suggest that:
Appery('toggle').val('off');
Appery('toggle').slider( "refresh" );

will achieve this. Since
http://devcenter.appery.io/documentat...

appears to contain an incorrect example, it would be great if it could be updated in line with this solution

ewan

Return to “Issues”