Grails remoteLink不使用我的javascript
我的gsp中有这个代码,我在创建和编辑时使用它Grails remoteLink不使用我的javascript,javascript,css,grails,Javascript,Css,Grails,我的gsp中有这个代码,我在创建和编辑时使用它 <div class="fieldcontain ${hasErrors(bean: componentsInstance, field: 'inventoryItem', 'error')} required"> <label for="inventoryItem"> <g:message code="components.inventoryItem.label" default="Inven
<div class="fieldcontain ${hasErrors(bean: componentsInstance, field: 'inventoryItem', 'error')} required">
<label for="inventoryItem">
<g:message code="components.inventoryItem.label" default="Inventory Item" />
<span class="required-indicator">*</span>
</label>
<g:select class="select2" style="width:30% !important" id="inventoryItem" name="inventoryItem.id" from="${rms.InventoryItem.list()}" optionKey="id" optionValue="name" required="" value="${componentsInstance?.inventoryItem?.id}"/>
</div>
现在看起来像这样
当我编辑模态的主体时,我使用remoteLink更新模态
<div id="componentsShown_${ci.id}">
<div class="modal-body">
<ol class="property-list">
<g:if test="${ci?.inventoryItem}">
<li class="fieldcontain">
<span id="inventoryItem-label" class="property-label"><g:message code="components.inventoryItem.label" default="Inventory Item" /></span>
<span class="property-value" aria-labelledby="inventoryItem-label">${ci?.inventoryItem?.name?.encodeAsHTML()}</span>
</li>
</g:if>
<g:if test="${ci?.quantity}">
<li class="fieldcontain">
<span id="quantity-label" class="property-label"><g:message code="components.quantity.label" default="Quantity" /></span>
<span class="property-value" aria-labelledby="quantity-label"><g:fieldValue bean="${ci}" field="quantity"/></span>
</li>
</g:if>
<g:if test="${ci?.units}">
<li class="fieldcontain">
<span id="units-label" class="property-label"><g:message code="components.units.label" default="Units" /></span>
<span class="property-value" aria-labelledby="units-label"><g:fieldValue bean="${ci}" field="units"/></span>
</li>
</g:if>
</ol>
</div>
<g:form>
<g:hiddenField name="id" value="${ci.id}" />
<div class="modal-footer">
<button type="submit" class="btn btn-primary pull-right" name="_action_deleteComponents" value="deleteComponents">
<span class="glyphicon glyphicon-floppy-remove"></span> Delete
</button>
<g:remoteLink id="${ci.id}" controller="superAdmin" action="editComponents" update="componentsShown_${ci.id}">
<button type="submit" class="btn btn-primary pull-right" style="margin-right:5px;">
<span class="glyphicon glyphicon-floppy-remove"></span> Edit
</button>
</g:remoteLink>
</div>
</g:form>
那么,您的问题是选择框的样式吗?如我所见,您使用select2插件来实现这一点?部件有问题吗?医生说。。。或者是一个元素id要更新的字符串,因此我希望DivComponentShown_${ci.id}的全部内容被替换为控制器返回/呈现的文本。@baxxabit是的,我想我可能需要重新初始化javascript,因为remotelink@nickdos对更新的部分看起来像above@nickdos我确实使用了remoteLink的onSuccess属性。现在可以用了,谢谢
<div id="componentsShown_${ci.id}">
<div class="modal-body">
<ol class="property-list">
<g:if test="${ci?.inventoryItem}">
<li class="fieldcontain">
<span id="inventoryItem-label" class="property-label"><g:message code="components.inventoryItem.label" default="Inventory Item" /></span>
<span class="property-value" aria-labelledby="inventoryItem-label">${ci?.inventoryItem?.name?.encodeAsHTML()}</span>
</li>
</g:if>
<g:if test="${ci?.quantity}">
<li class="fieldcontain">
<span id="quantity-label" class="property-label"><g:message code="components.quantity.label" default="Quantity" /></span>
<span class="property-value" aria-labelledby="quantity-label"><g:fieldValue bean="${ci}" field="quantity"/></span>
</li>
</g:if>
<g:if test="${ci?.units}">
<li class="fieldcontain">
<span id="units-label" class="property-label"><g:message code="components.units.label" default="Units" /></span>
<span class="property-value" aria-labelledby="units-label"><g:fieldValue bean="${ci}" field="units"/></span>
</li>
</g:if>
</ol>
</div>
<g:form>
<g:hiddenField name="id" value="${ci.id}" />
<div class="modal-footer">
<button type="submit" class="btn btn-primary pull-right" name="_action_deleteComponents" value="deleteComponents">
<span class="glyphicon glyphicon-floppy-remove"></span> Delete
</button>
<g:remoteLink id="${ci.id}" controller="superAdmin" action="editComponents" update="componentsShown_${ci.id}">
<button type="submit" class="btn btn-primary pull-right" style="margin-right:5px;">
<span class="glyphicon glyphicon-floppy-remove"></span> Edit
</button>
</g:remoteLink>
</div>
</g:form>