2016-05-13 133 views
0

我使用gMapsLatLonPicker plugin上一個模式(基礎6顯示),問題是,我意識到我需要爲了在模態工作,例如手動加載插件:谷歌地圖API和gMapsLatLonPicker

$('#modal').on("open.zf.reveal", function(ev,elem) { 
    /*when the modal fires open*/ 
    $(document).gMapsLatLonPicker().init($(this)); /*Init the plugin*/ 
}); 

但是我不想在每次有人打開模式時初始化插件,你知道是否有另一種方法嗎?

回答

0

你可以嘗試這樣的事情

var first_time = true; 

$('#modal').on("open.zf.reveal", function(ev,elem) { 
    /*when the modal fires open*/ 
    if(first_time==true){ 
     $(document).gMapsLatLonPicker().init($(this)); /*Init the plugin*/ 
     first_time=false; 
    } 
}); 
+0

認爲可能存在更好的解決方案,但是,是的,這是一個方便, – user3068333