1

亲爱的,我正在使用 jQuery Grid 来显示用户管理数据。当我点击“+”号时,我会弹出一个对话框,我可以在其中创建一个新用户。我使用服务器端调用来填充级联列表。

当我提交请求时:失败,甚至成功时,“正在加载...”按钮似乎永远不会消失。我担心我会留下一些资源,或者更糟。由于我继承了这个应用程序,并且没有任何 jQuery 经验,我希望你能帮助我。如果这真的很简单,我提前道歉;但是,我在网上找不到任何可以帮助我解决这个问题的东西。

我正在使用 Struts 2 和 jQuery;但是,我不认为我们使用 jQuery Struts 2 插件。提前致谢。

这是代码:

<%@ include file="/WEB-INF/jsp/fragments/directive.jsp" %>  

<s:if test="hasActionErrors()">
<div class="error">
    <s:actionerror/>
</div>
</s:if>
<s:form action="userAdminCreateSubmit" namespace="/ti/tmsportal/ga" onsubmit="return false;" >
<s:textfield key="user.username" required="true" />
<s:textfield key="user.firstName" required="true" />
<s:textfield key="user.middleInitial" />
<s:textfield key="user.lastName" required="true" />
<s:textfield key="user.email" required="true" />
<s:textfield key="user.phone" required="true" />            
<s:select key="user.organizationId" list="organizations" listKey="value" listValue="label" required="true" onchange="changeWorkgroups(this.value);changeRoles(this.value);" />
<s:select key="user.workgroupId" list="workgroups" listKey="value" listValue="label" onchange="changeLocations(this.value);" />
<s:select key="user.locationId" list="locations" listKey="value" listValue="label" />
<s:select key="user.portalRole" list="roles" listKey="value" listValue="label" emptyOption="true" required="true" onchange="changeLevels(this.value);" />
<s:select key="user.levelCode" list="levels" listKey="value" listValue="label" emptyOption="true" required="true" />

</s:form>   

<s:url action="lookup" var="workgroupLookupUrl" >
<s:param name="type">workgroupsInOrganization</s:param>
</s:url>

<s:url action="lookup" var="locationLookupUrl" >
<s:param name="type">locationsInWorkgroup</s:param>
</s:url>

<s:url action="lookup" var="roleLookupUrl" >
<s:param name="type">rolesForOrg</s:param>
</s:url>

<s:url action="lookup" var="levelLookupUrl" >
<s:param name="type">levelsForRole</s:param>
</s:url>


<script>
function changeWorkgroups(key)
{
    $('#userAdminCreateSubmit [name="user.workgroupId"]').load('<s:property value="#workgroupLookupUrl" />&key=' + key + ' option',
        function(responseText, textStatus, XMLHttpRequest) {
            changeLocations();
            setVisibility();
        }
    );      
}

function changeLocations(key)
{
    $('#userAdminCreateSubmit [name="user.locationId"]').load('<s:property value="#locationLookupUrl" />&key=' + key + ' option',
        function(responseText, textStatus, XMLHttpRequest) {
            setVisibility();
        }
    );
}

function changeRoles(key)
{
    $('#userAdminCreateSubmit [name="user.portalRole"]').load('<s:property value="#roleLookupUrl" />&key=' + key + ' option',
        function(responseText, textStatus, XMLHttpRequest) {
            changeLevels($('#userAdminCreateSubmit [name="user.portalRole"]').value());
        });
}

function changeLevels(key)
{
    $('#userAdminCreateSubmit [name="user.levelCode"]').load('<s:property value="#levelLookupUrl" />&key=' + key + ' option');
}   

function setVisibility()
{
    $('#userAdminCreateSubmit [name="user.workgroupId"]').parents('tr').toggle(
        $('#userAdminCreateSubmit [name="user.workgroupId"] option[value!=""]').size() > 0
    );

    $('#userAdminCreateSubmit [name="user.locationId"]').parents('tr').toggle(
        $('#userAdminCreateSubmit [name="user.locationId"] option[value!=""]').size() > 0
    );
}

$(function()
{
    $('.button').button();
    setVisibility();
    addFieldHint('user.receiveNotifications', '<s:text name="content.help.receiveNotifications" />');       
    addFieldHint('user.username', '<s:text name="content.help.username" />');
});

function submitUserAdminCreate()
{
    $.post('<s:url action="userAdminCreateSubmit" namespace="/ti/tmsportal/ga" />', $('#userAdminCreateSubmit').serialize(),
        function(data) {
            $('#userAdminDialog').empty().append(data);
        }
    );
}
</script>
4

1 回答 1

0

要修复您的 JS 错误,只需更改

$('#userAdminCreateSubmit [name="user.portalRole"]').value()

$('#userAdminCreateSubmit [name="user.portalRole"]').val()
于 2012-11-10T23:52:13.863 回答