これは、スワイプ削除のような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();
});