我有一個列表視圖,它可以從本地數據庫中獲取數據。我想添加和taphold事件的列表項目,所以我使用taphold從這個網站http://www.raymondcamden.com/index.cfm/2012/5/23/Context-Menu-Example-with-jQuery-Mobile例如,但是當在模擬器上運行此代碼時它的工作正常,但是當我試圖將其實施到代碼中,我正在使用它不能正常工作給予警告那它在Taphold事件,但不會在這裏營造出sampledialog箱,我現在用的是代碼:使用taphold不能在phonegap中用danymatically創建listview Android
function createlist(){
alert("I am in create list");
db.transaction(function(tx){
tx.executeSql(select_nameUserDetails,[],function(tx,results){
$('#name').empty();
alert("from list "+results.rows.length);
if(results.rows.length>0)
{
for(var i=0;i<results.rows.length;i++)
{
alert(i);
$('#name').append('<li><p class="namelist" id="s'+i+'" onclick="selectname('+results.rows.item(i).id+')">'+results.rows.item(i).frist_name+'</p></li');
temp_id=results.rows.item(i).id;
dataobj[temp_id]=results.rows.item(i).frist_name;
alert(dataobj[temp_id]);
}
else{
alert("No data present");
}
});
$(document).on("taphold",".namelist",function(event){
alert("I am in taphold event");
event.stopPropagation();
$(this).simpledialog2({
mode:"blank",
headerText:"Image Options",
showModal:false,
forceInput:true,
headerClose:true,
blankContent:"<ul data-role='listview'><li><a href=''>Edit</a></li><li><a href=''>Delete</a></li></ul>"
});
});
});
}
這裏是js和css文件:
<link rel="stylesheet" href="contactcss/jquery.mobile-1.3.1.min.css">
<link rel="stylesheet" href="css/jquery.mobile.simpledialog.min.css">
<script src="js/jquery.js"></script><script src="js/index.js"></script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>
<script src="js/jquery.mobile.simpledialog2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/cordova-2.7.0.js"></script>
這裏該html代碼:
<div data-role="Content" >
<div data-role="listview" id="field">
<ul class="Name" id="name" data-role="listview" data-inset="true" data-theme="b">
</ul>
</div>
logcat的錯誤我得到:
07-13 17:29:33.145: D/CordovaLog(2696): TypeError: Result of expression 'o[0]' [undefined] is not an object.
07-13 17:29:33.145: E/Web Console(2696): TypeError: Result of expression 'o[0]' [undefined] is not an object. at file:///android_asset/www/js/jquery.mobile-1.3.1.min.js:4
在此先感謝
任何控制檯錯誤? – krishgopinath