这将帮助您创建像滑动删除一样的 iphone。这是参考http://forum.jquery.com/topic/adding-an-iphone-style-swipe-to-delete-button-to-a-listview
EXERCISEDESCRIPTION.swipeDelete = function(exerciseSetsListview, callback) {
var listViewJq = '#'+exerciseSetsListview;
$(listViewJq).children().each(function(){
var child = $(this);
var childId = child.attr('id');
var splitId = childId.split("_");
var childIdVar = '#'+childId;
var childIdBtnVar = splitId[0]+'_button_'+splitId[1];
var childIdBtnVarJq = '#'+childIdBtnVar;
$(childIdVar).bind('swiperight', function() {
$(childIdVar).prepend('<a href="#" id="'+childIdBtnVar+'" class="aSwipeBtn" data-theme="b" data-inline="true" data-role="button">Delete</a>');
$(childIdBtnVarJq).button();
$(childIdVar).unbind('swiperight');
$(childIdBtnVarJq).bind('click tap', function() {
$(childIdVar).remove();
var splitButtonId = childIdBtnVarJq.split("_");
callback(splitButtonId[2]);
});
});
});
};
用法:
EXERCISEDESCRIPTION.swipeDelete('exerciseSetsListview',
function(e) {
EXERCISEDESCRIPTION.setsObj.splice(e,1);
EXERCISEDESCRIPTION.repopulateSets();
});