我在动态页面中有选项卡。这些标签在按下时效果很好,但我想添加一个滑动功能,以便用户也可以滑动到下一个标签。Jquery移动滑动
这是我的努力让刷卡功能的工作
function goToMatchDetailPage(matchHome, matchAway){
first_part_id = matchHome.substring(0,2);
sec_part_id = matchAway.substring(0,2);
var id = first_part_id.concat(sec_part_id);
//create the html template
var matchPage = $("<div data-role='page' data-url=dummyUrl><div data-role='header'><h1>"
+ matchHome + "</h1></div><div data-role='content'><div data-role='tabs'>"
+ "<div data-role='navbar'>"
+ "<ul>"
+ "<li><a href='#fragment-1'>" + matchHome + "</a></li>"
+ "<li><a href='#fragment-2'>" + matchAway + "</a></li>"
+ "</ul>"
+ "</div>"
+ "<div id='fragment-1'>"
+ "<p>This is the content of the tab 'One', with the id fragment-1.</p>"
+ "</div>"
+ "<div id='fragment-2'>"
+ "<p>This is the content of the tab 'Two', with the id fragment-2.</p>"
+ "</div></div></div>");
//append the new page to the page contanier
matchPage.appendTo($.mobile.pageContainer);
//go to the newly created page
$.mobile.changePage(matchPage);
尝试这里是行不通
$(function(){
// Bind the swipeleftHandler callback function to the swipe event on div.box
$("div").on("swipeleft", swipeleftHandler);
// Callback function references the event target and adds the 'swipeleft' class to it
function swipeleftHandler(event){
//go to the newly created page
$.mobile.changePage('#fragment-2');
}
});
}
你尝试'$( “格”).bind(“swipeleft “,swipeleftHandler);' – sharshi
当你没有为每个按钮点击加载页面时,使用'document.ready'函数是一个坏主意,请查看事件文档:http://demos.jquerymobile.com/ 1.2.1 /文档/ API/events.ht毫升。在创建新元素时,初始绑定不会影响这些元素,因此您必须重新绑定到新元素或使用委托事件处理程序。有关Stack Overflow的大量信息。 – Jasper
尝试两个仍然没有工作 – user3210416