只是试图在 BS 弹出窗口中使用 ajax formRemote。一个简单的表单可以工作,但 ajax 实现不行:
1)gsp代码
<div id="addfolder">
<a href="#" class="btn" id="nrfolder" rel="popover">
<i class="icon-folder-close icon-large"></i></a><%--<g:message code="folder" args="[entityName]" default="New Folder"/>--%></a>
</div>
<div id="newRootFolder" style="display:none;">
<form class="form-inline" style="width:280px;">
<g:formRemote name="createRootFolder" url="[controller:'folders',action:'create']" onLoading="showModalSpinnerNewFolder();" onComplete="hideModalSpinnerNewFolder();" onSuccess="doResponseNewFolder(data);" >
<g:textField name="folderName" class="input-small" type="text" placeholder="New folder"/>
<input type="submit" value="Create" class="btn btn-info" />
<a href="#" class="btn" onclick="$('#nrfolder').popover('hide')"/>Cancel</a>
</g:formRemote>
</g:formRemote>
</form>
</div>
2) 使用 jquery 的弹出框调用
$('#nrfolder').popover({placement:'right',title:'New Root Folder',html:true,content: function() { return $('#newRootFolder').html();} });
3)jquery成功事件:doResponseNewFolder函数
function doResponseNewFolder(data) {
alert('toto' + data.success);
if (data.success == 'true') {
var msg = data.msg;
// reload tree view
$('#tree').dynatree('getTree').reload();
} else {
var msg = $('<ul class="errors">');
for (var i = 0; i < data.errorList.length; i++) {
msg.append('<li>' + data.errorList[i] + "</li>");
}
}
$('#new_folder_msg').html(msg);
$('#new_folder_msg').show();
}
任何的想法?