【发布时间】:2013-04-26 15:39:52
【问题描述】:
我正在使用此管理面板模板确认框。
http://themepixels.com/main/themes/demo/webpage/shamcey/elements.html
当我点击确认框的 ok 按钮时,ajax 部分不起作用。
我不明白为什么它不起作用?
这是我的代码:
//jquery部分
<script>
jQuery(document).ready(function(){
if(jQuery('.confirmbutton').length > 0) {
jQuery('.confirmbutton').click(function(){
jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
if(r==true){
var article_id=$(this).attr("id");
$.ajax({
type:"POST",
url: "<?php echo site_url()?>admin/delete",data: "id="+article_id+"&categ=article",asynchronous: true,cashe: false,beforeSend: function(){},
success: function(){
$('#delete_link_'+article_id).hide();
}
});
}
});
});
}
});
</script>
//HTML
<tr id="delete_link_15">
<td>15</td>
<td>1</td>
<td>asg</td>
<td>etc</td>
<td>etc</td>
<td>
<span class="btn-group">
<a class="btn btn-small confirmbutton"><i class="icon-trash"></i></a>
</span>
</td>
</tr>
【问题讨论】:
-
你能不能把:
console.log('Before If')放在if(r==true)条件之前,console.log('Inside If')放在if(r==true){之后 -
var parca=jQuery(this).parent('span').parent('td').parent('tr').attr("id");这部分不起作用。
-
var article_id=$(this).attr("id");- 检索id属性的上下文无效。
标签: jquery codeigniter dialog confirm