【问题标题】:Jquery mobile - Weird behaviour of hrefJquery mobile - href 的奇怪行为
【发布时间】:2012-10-12 17:22:35
【问题描述】:

我正在使用 jquery (jquery.mobile-1.1.0.min)、jquery mobile (jquery.mobile-1.1.0) 和 phoneGap。

在queryWLSuccess中,每个链接根据数据库都有唯一的ID,当我传输包含ID的名称时,单击每个链接将显示链接的详细信息。当我不使用 href='#' (正确显示每个链接 ID ='1',ID='2',...)但添加 href='#'(显示每个链接 ID = '2', ID='2',ID='2',...所有链接的 ID 相同)

这种奇怪的行为是怎么回事?如何导航到其他外部页面?点击时我需要导航到另一个页面。

JS 文件

---DATABASE---
function queryWLDB(tx) {
        tx.executeSql("SELECT * FROM WORD WHERE Level='"+ sessionStorage.StudyLevel +"'ORDER BY Word_ID" , [], queryWLSuccess, errorCB);

    }

     function queryWLSuccess(tx, results) {

        var len = results.rows.length

        for (var i=0; i<len; i++){
            $("<li class='content'><a  ***href='#'*** name='"+results.rows.item(i).ID+"'>"+results.rows.item(i).Eng+"</a></li>").appendTo(".wordList");
        }           
    }

---JQUERY MOBILE---
$( document ).delegate("#list", "pageshow", function() {
   $('.content').remove();
   onDeviceReady();
   db.transaction(queryWLDB, errorCB);
}); 

$("li.content a").live('click', function(){
    alert("ID =  "+$(this).attr("name")); 

});

INDEX.HTML 单词表页面

<div data-role="page" id="wordList">

<div data-role="content">   
    <ol class="list">

    </ol>

</div>

</div><!-- WordList page -->

【问题讨论】:

标签: jquery cordova jquery-mobile href


【解决方案1】:

我用的时候解决了

$.mobile.changePage("anotherpage.html", {transition: "slide"});

何时用于点击监听器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多