• ajax局部更新


    js
    
    //点击启用
            $(".status").on("click",function(){
                var id = $(this).attr("statusId");
                var customName = $(this).attr("customName");
                var customStatus = $(this).attr("value");
                var statusId = $(this).attr("statusId");
                if(customStatus == 1){
                    strcustomStatus = "停用";
                }else{
                    strcustomStatus = "启用";
                }
                alert(customStatus);
                //alert(customName);
                //alert(id);
                ymPrompt.win({ 
                                260,
                                   height:150,
                                icoCls: '',
                                message:'<div style="padding-top:25px;" class="message" align="center">您确定要'+strcustomStatus+'【'+customName+'】这个客户吗?</div>',
                                titleBar:false,
                                winPos:'c',
                                   btn:[['OK','ok'],['Cancel','no']],
                                   handler:function getButton(btn){
                                       if(btn == "ok"){
                                           $.ajax({
                                               type:"Post",
                                               data:{"customStatus":customStatus,"id":id},
                                               dataType:"json",
                                               url:classpath+"/updatecustomStatus",
                                               success:function(data){
                                                   if(data.customStatus==1){
                                                       //点击
                                                       $("span[statusId='"+statusId+"']").val(1);
                                                       $("span[statusId='"+statusId+"']").html("<font color='red'>停用</font>");
                                                       $("#"+statusId+"").val(0);
                                                       $("#"+statusId+"").html("启用");
                                                   }else{
                                                       $("span[statusId='"+statusId+"']").val(0);
                                                       $("span[statusId='"+statusId+"']").html("启用");
                                                       $("#"+statusId+"").val(1);
                                                       $("#"+statusId+"").html("<font color='red'>停用</font>");
                                                   }
                                               }
                                           });
                                       }
                                   }
                });

    页面

        <s:form  id="form" method="post">
            <table align="center" width="960" height="30" border="1px solid" id="find"/>
                <tr align="center" cellpadding="0">
                    <th width="65px">序号</th>
                    <th width="220px">客户名称</th>
                    <th width="200px">法人代表</th>
                    <th width="180px">注册时间</th>
                    <th width="80px">类型</th>
                    <th width="80px">状态</th>
                    <th width="135px">操作</th>
                </tr>
                  <s:iterator value="customsPageSupport.result" var="c" status="status">
                <tr align="center">
                    <td>
                        <s:property value="#status.index+1"/>
                    </td>
                    <td><s:property value="customName"/></td>
                    <td><s:property value="bossName"/></td>
                    <td><s:date name="regDatetime" format="yyyy-MM-dd"/></td>
                    <td><s:property value="customTypeName"/></td>
                    <td>
                        <span id="${c.id}" style="color:green" firststatusId="${c.id }" value="${c.customStatus }"><s:if test="customStatus == 1">启用</s:if>
                        <font color="red"><s:else>停用</s:else></font></span>
                    </td>
                    <td>
                        <span style="cursor:pointer" class="find" findId="${c.id }" >查看</span>                    
                        <span style="cursor:pointer" class="update" updateId="${c.id }">修改</span>
                        <span id="secondspan" style="color:green;cursor:pointer" class="status" statusId="${c.id }" value="${c.customStatus }" customName="${c.customName }"><s:if test="customStatus == 0">启用</s:if>    
                        <font color="red"><s:else>停用</s:else></font></span>                    
                    </td>
                </tr>
            </s:iterator>
  • 相关阅读:
    winform窗体扁平化设置,窗体移动,关闭
    WPF按钮控件模板
    C#连接Sqlite报错:{"试图加载格式不正确的程序。 (异常来自 HRESULT:0x8007000B)"}
    C#SQLite使用教程笔记
    C#自定义控件导航菜单(自定义事件,属性)
    LCS局域网屏幕监控系统安装指导
    System.Data.SQLite.dll 未安装或者版本冲突,按下面步骤操作即可 1、从Nuget卸载所有项目的System.Data.SQLite.dll 和SqlSugar,检查引用中是否还存在,存在直接删掉引用,然后Nuget重新安装即可
    C#项目脱落NuGet
    JavaScript跨域总结与解决办法
    回流与重绘:CSS性能让JavaScript变慢?
  • 原文地址:https://www.cnblogs.com/xuerong/p/5062665.html
Copyright © 2020-2023  润新知