2015-08-30 139 views
0

我正在使用Wordpress和JQuery Mobile版本1.4.5。我的問題是下面的代碼不工作只有$(document).ready工作正常。我在wordpress中是新手,我不知道什麼是錯的。JQuery Mobile頁面事件未觸發

$(document).on('pagecreate','[data-role=page]', function(){ 
    console.log('PAGECREATE'); 
}); 
$(document).on('pageinit','[data-role=page]', function(){ 
    console.log('PAGEINIT'); 
}); 
$(document).on('pagebeforeshow','[data-role=page]', function(){ 
    console.log('PAGEBEFORESHOW'); 
}); 
$(document).on('pageshow','[data-role=page]', function(){ 
    console.log('PAGESHOW'); 
}); 
$(document).on('mobileinit','[data-role=page]', function(){ 
    console.log('mobileinit'); 
}); 

$(document).ready(function(){ 
    console.log("ready"); 
}); 

我這是怎麼插入JQM在funtion.php

wp_deregister_script('jquerypremobile'); 
wp_register_script('jquerypremobile', get_template_directory_uri() .'/jmobile/jquery.mobile-1.4.5.js', array('jquery'), '1.0'); 
wp_enqueue_script('jquerypremobile'); 

這是正確的?

回答

0

我認爲按順序調用每個函數。因爲jquery按順序編譯,所以更好地檢查事件的順序然後調用。希望它會有所幫助。