使用JQ和JQM開發phonegap應用程序,這個奇怪的問題真的讓我很難過。我真的可以使用我能得到的所有幫助,謝謝大家!。事件綁定中的數據()
的硬類解釋,但只是無法得到。數據()在2個動態綁定的事件處理程序的工作同樣在這2個事件處理程序看起來幾乎幾乎相同。我必須錯過了一些地方..唉..
HTML
<ul data-role="listview" id="notelist" data-split-icon="minus" data-split-theme="c">
<li id="entrytemplate" style="display:none">
<a class="btnpopupdetails" href="#" data-position-to="window" data-rel="popup" data-transition="pop">
<h3>TEMPLATE Faulty lift</h3>
<p>TEMPLATE Lift A1, at lobby, Skyscraper Plaza, was reported broken down on 25th Dec 2012</p>
</a>
<a class="btndelete" href="#" data-position-to="window" data-rel="popup" data-transition="pop">Delete</a>
</li>
</ul>
JS
// row is a single row from a resultset of a successful sql query
newrow.data('rowid', row.id); // integer
newrow.data('rowtitle', row.txttitle); // text
newrow.data('rowdescription', row.txtdescription); // text
console.log(newrow.data('rowtitle')); // value retrieved and displayed fine!
console.log(newrow.data('rowdescription')); // value retrieved and displayed fine!
newrow.appendTo('#notelist');
newrow.find('h3').text(row.txttitle);
newrow.find('p').text(row.txtdescription);
newrow.find('.btnpopupdetails').click(function() {
selectedrow = $(this).parent();
selectedrowid = selectedrow.data('rowid');
selectedrowtitle = selectedrow.data('rowtitle');
selectedrowdscription = selectedrow.data('rowdescription');
console.log(selectedrow.data('rowid')); // "TypeError: 'undefined' is not an object"
console.log(selectedrow.data('rowtitle')); // "TypeError: 'undefined' is not an object"
console.log(selectedrow.data('rowdescription')); // "TypeError: 'undefined' is not an object"
});
newrow.find('.btndelete').click(function() {
selectedrow = $(this).parent();
selectedrowid = selectedrow.data('rowid');
selectedrowtitle = selectedrow.data('rowtitle');
selectedrowdscription = selectedrow.data('rowdescription');
console.log(selectedrow.data('rowid')); // value retrieved and displayed fine!
console.log(selectedrow.data('rowtitle')); // value retrieved and displayed fine!
console.log(selectedrow.data('rowdescription')); // value retrieved and displayed fine!
如果沒有可用的例子也很難指出來..你能創建一個小提琴??。 –
感謝您的幫助和編輯,夥計們,真的很感激! :-) –