Grails remoteLink不使用我的javascript

时间:2014-02-16 16:05:27

标签: javascript css grails

我在创建和编辑

时使用的gsp中有这个代码
<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>

看起来像这样,忽略数量和单位字段enter image description here

它在创建时工作正常,但是当我使用remoteLink以某种方式编辑时,我的class="select2"的javascript无效。

<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>

现在看起来像这样 enter image description here

当我编辑模态的主体时,我使用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>

0 个答案:

没有答案