javascript - Issue on Having Toggle Button with jquery -


i have button in google map suppose set drawing manager null when clicked

$("#pauseedit").on("click",function(){         drawingmanager.setdrawingmode(null);  }); 

and working fine can please let me know how make toggle like

$("#pauseedit").on("click",toggle(){  drawingmanager.setdrawingmode(null); ,  drawingmanager.setdrawingmode(polygon);   }); 

thanks

i don't remember if can access drawingmanager.drawingmode value. if do, can testing if:

$( "#pauseedit" ).on( "click", function () {     if ( drawingmanager.drawingmode === null ){         drawingmanager.setdrawingmode( polygon );     }else{         drawingmanager.setdrawingmode( null );     } } ); 

if can't, use class on #pauseedit control that:

$( "#pauseedit" ).on( "click", function () {     if ( $(this).hasclass('drawingmodepolygon') ){         //if has class, on edit mode, turn off         $(this).addclass('drawingmodenull').removeclass('drawingmodepolygon');         drawingmanager.setdrawingmode( null );     }else{         //otherwise add class , change drawing         $(this).addclass('drawingmodepolygon').removeclass('drawingmodenull');         drawingmanager.setdrawingmode( polygon );     } } ); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -