2013-04-25 55 views
0

这里是HTML代码:

<div data-role="page" id="mainMenu"> 
    <div data-role="header"> 

    </div> 
    <div data-role="content"> 
    <ul data-role="listview" data-inset="true" 
             style="margin-top:50%; margin-left:20%;"> 
    <li id="prayerId" data-theme="b"><a href="#"><img 
               src="css/images/namazimage.jpg" />PRAYERS </a> 
             </li> 
    <li id="goalId" data-theme="e"><a href="#"><img 
               src="css/images/namazimage.jpg" />GOAL </a> 
             </li> 

    </ul> 
    </div> 
    </div> 
    <!-- //////////////////////// PRAYER PAGE START ////////////////////////////////////// --> 
     <div data-role="page" id="prayer"> 
      <div data-role="header" data-theme="b"></div> 
      <div data-role="content"></div> 
      <div data-role="footer" data-theme="e" data-position="fixed"> 

       <div data-role="navbar"> 

        <ul> 
         <li id="namazId"><a href="#" data-role="tab" data-icon="grid">NAMAZ</a></li> 
         <li id="fastId"><a href="#" data-role="tab" data-icon="grid">FAST</a></li> 
        </ul> 
       </div> 
      </div> 

     </div> 

<!-- //////////////////////// PRAYER PAGE END ////////////////////////////////////// --> 

这个S这是写在单独的js文件的代码:

$('#mainMenu').live('pageinit', function() { 
    $('#prayerId').off('click').on('click', function() { 
     alert("prayer id"); 
     $.mobile.changePage("#prayer", null, true, true); 
     //$.mobile.changePage('#loginPage', null, true, true); 

    }); 
}); 
$('#prayer').live('pageinit',function() 
{ 
    alert("prayer page"); 
    $('#namazId').off('click').on('click', function() { 
     alert("namaz page"); 
     //$.mobile.changePage('#mainMenu', null, true, true); 
     $.mobile.changePage('#namazPage', null, true, true); 

    }); 
}); 

但在这里变化页不能正常工作的jQuery的所有引用和已添加科尔多瓦使用cordova 2.0.0和jquery 1.7.1

+0

尝试'$ .mobile.changePage( '#namazPage')'不为空,真正的,真实的。 – Omar 2013-04-25 12:19:58

+0

@omar仍然没有任何更改 – nida 2013-04-25 12:33:21

+0

@ user1668447检查您的标签。通常'changePage'在没有关闭标签或额外标签时无法工作。 – 2013-04-25 12:57:06

回答

0

pageinit事件中删除click事件。 pageinit仅在页面初始化时触发一次,之后,任何附加到它的事件都将被忽略。

$('#prayerId').off('click').on('click', function() { 
alert("prayer id"); 
$.mobile.changePage("#prayer", null, true, true); 
}); 

$('#namazId').off('click').on('click', function() { 
alert("namaz page"); 
$.mobile.changePage('#namazPage', null, true, true); 
}); 

Demo

+0

的问题,但我不想写这个代码在我的脚本标记,因为这么多人aer在一个项目多数民众赞成为什么要避免冲突想要把我的代码放在我的单独的js文件中,名为namaz.js我怎么能写我的代码,请解释 – nida 2013-04-25 13:59:27

+0

你可以这样做'$(document).on('click','#prayerId',function )'或'$('a')。on('click','#prayerId',function()'或'$(document).on('click','a#prayerId',function()'。它可以用多种方式编写,也可以用'#pageID'替换'document'。记住每个元素都应该有一个唯一的'id',不能被使用两次。@ user1668447 – Omar 2013-04-25 14:03:12

+0

你有jqplot与从sqlite数据库获取数据? – nida 2013-04-25 14:06:19

相关问题