toggle switch slide to trigger a JS function
in jqm,
this is a working toggle switch:
- <form name="BRAND" >
- <select data-role="slider" name="MODEL" id="test">
- <option value="off">sedan</option>
- <option value="on"> sportster</option>
- </select> </form>
and this is a way of making the switch trigger a function
slidestop triggered at the end of an interaction with the slider. Includes drags and taps.
- $( ".selector" ).on( 'slidestop', function( event ) { ... });
how to connect them?
I have tried using
this
- <script>
- $( ".selector" ).on( 'slidestop', myFunction())
- function myFunction()
- {
- document.write("works!");
- };
- </script>
and this
- $( "#testo" ).on( 'slidestop', myFunction())
- function myFunction()
- {
- document.write("works!");
- };
the former works before triggering, and the latter, where i try to connect the event to more specifically a switch with id="testo", it never works.