2015-08-30 235 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按顺序编译,所以更好地检查事件的顺序然后调用。希望它会有所帮助。