当前位置: 代码迷 >> Web前端 >> jquery自定义属性,解决List中按钮传值有关问题
  详细解决方案

jquery自定义属性,解决List中按钮传值有关问题

热度:82   发布时间:2012-11-13 10:00:50.0
jquery自定义属性,解决List中按钮传值问题
     用JQuery对前台代码进行规范,遇到一些问题。对集合数据进行遍历时,操作单条数据的增、删、改、查,需要传递一些参数进行后台的处理。
      本人在项目中用标签的自定义属性传值,然后jquery使用attr便可访问到,这样可以减少javascript脚本中代码和数据的耦合


下面是例子代码,仅供参考:
<script type="text/javascript">
$(document).ready(function(){
//ajax删除
$(".btn_delete").click(function(){
ret = window.confirm('${texts['dtaq.common.delete.msg']}');
if(ret){
$.ajax({
   type: "POST",
url: 'sysCodeRuleitemAction.do?method=delete'
+'&id='+$(this).attr("paramId")
+'&ruleid='+$(this).attr("paramRuleid"),
   success: function(msg){
  $('#childbody').html(msg);
   }
});
}
});
//
});
</script>
<fieldset>
<legend>
[***********]
</legend>
<table class="defTable" >
<thead>
<tr >
<th width="5%" >序号</th>
<th width="25%">*****</th>
<th width="10%" >*****</th>
<th width="10%" >*****</th>
<th width="25%" >*****</th>
</tr>
</thead>
<c:forEach items="${sysCodeRuleitems}" varStatus="index"
var="sysCodeRuleitem">
<tr class="tr07">
<td>${index.count}</td>
<td>${sysCodeRuleitem.ruletype}&nbsp;</td>
<td>${sysCodeRuleitem.rulecontent}&nbsp;</td>
<td>${sysCodeRuleitem.orderno}&nbsp;</td>
<td>
<div >
        <input type="button" class="button1 btn_edit" 
        value="${texts['button.edit']}"
        paramId="${sysCodeRuleitem.id}"
        paramRuleid="${param.ruleid}"/>
<input type="button" class="button1 btn_delete"
value="${texts['button.delete']}"
paramId="${sysCodeRuleitem.id}"
paramRuleid="${param.ruleid}"/>
</div>
</td>
</tr>
</c:forEach>
</table>
</fieldset>
1 楼 虚弱的java 2011-08-11  
   
  相关解决方案