livequery - تأكيد ()
-
06-07-2019 - |
سؤال
وأنا لا أحصل على لماذا هذا تأكيد () حرائق الاستدعاء على الرغم من انني ضرب "لا". هل تستطيع أن تقول لي ما أفعله خطأ؟
$('.deleteButton').livequery('click',function(){
if(confirm('Are you sure?')){
return true;
}else
{
return false;
}
return false;
});
ووHTML التوصيف:
<a class="smallbutton deleteButton" href="users.php?todo=delete&id=32">delete</a>
وراجعت وأنه لا عودة كاذبة، ولكن الصفحة لا يزال الموجهات إلى النقر على قيمة href. عادة، إذا أعود كاذبة، فإنه لا ينبغي، أليس كذلك؟
المحلول 3
وأعتذر: اتضح أنا كان ربط سلوك آخر لجميع المراسي داخل الحاوية المحتوى الرئيسي. وأضاف لي شرط استبعاد لdeleteButton وأنه يعمل بشكل جيد الآن.
وهنا هو بلدي النهائي، والعمل، والرمز:
var $tabs= $("#tabs").tabs({
fx: {
opacity: 'toggle'
},
load: function(event, ui) {
$('a', ui.panel).livequery('click',function() {
// we need to exclude the listNav buttons AND deleteButton buttons from this behavior
if($(this).parent().is(':not(".ln-letters")') && $(this).is(':not(".deleteButton")')){
$(ui.panel).load(this.href);
return false;
}
});
}
});
ويعمل سلوك زر الحذف مع بسيطة:
$('.deleteButton').live('click',function(e){
return confirm('Are you sure?');
});
نصائح أخرى
<a id="myId_1" href="#" class="deleteButton">delete</a>
$('.deleteButton').livequery('click',function(e){
e.stopPropagation();
if(confirm('Are you sure?')){
functionForDelete($(this).attr("id").split("_")[1]);
}
});
// OR ir you like goto href
<a id="myId1" href="url/delete/id.php?1" class="deleteButton">delete</a>
$('.deleteButton').livequery('click',function(e){
e.stopPropagation();
if(confirm('Are you sure?')){
window.location=$(this).attr("href");
}
});
تغيير livequery () ليعيش (). مسج يدعم نفس الوظيفة. مجرد اختبار في FF وانها عملت مع العيش () ولكن أبدا حتى أعطاني موجه مع livequery ()
وجرب هذا:
$('.deleteButton').livequery('click',function(e){
if (confirm('Are you sure?')) {
return true;
} else {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
return false;
}
});
لا تنتمي إلى StackOverflow