我想知道解决这个问题的最佳方法是使用PHP还是使用jQuery?当用户在编辑窗口中点击保存并提交更改时,不确定如何最好地将父页面的数据刷新在一起。启动窗口的代码如下:
<a href=\"/" . $Controller->Organization . "/community/edit_entry/?entry_id=" . $comEntry->getID() . "\" class=\"lightview\" title=\":: :: width:600, height:380, topclose:true\" rel=\"iframe\">edit</a>
在编辑页面中,这里是保存按钮的代码:
<fieldset class="submit actions">
<input id="signup" type="submit" name="signup" class="submitbtn" value="Save" />
<input type="button" class="secondary" name="butClose" id="butClose" value="Close" onclick="window.parent.Lightview.hide();" />
</fieldset>
答案 0 :(得分:0)
您可以使用jQuery并设置onclick()
事件处理程序,以便在单击“保存”按钮时刷新页面。此外,您可以根据需要应用表单验证,并且只有在满足所有要求时才刷新页面。如果不明确知道您的项目需要什么,您也可以通过AJAX完成所有工作,而不是重新加载页面。
答案 1 :(得分:0)
正如您在代码示例(“编辑”窗口)中看到的那样,shadowbox代码段使用window.parent
来访问父窗口元素以关闭该框。
您必须编写自己的JavaScript并在提交按钮中添加ID(类似butSubmit
)。像这样:
$('butSubmit').onClick({
// Reference to the parent window
var parentWindow = window.parent;
// Accessing the parent windows jQuery object
// and find the element with id #myTargetElement
var targetElement = parentWindow.$('#myTargetElement');
// Current window elements (with id #myInputField) value
var content = $('#myInputField').val();
targetElement.text(content); // May use .html() or .val()
parentWindow.Lightview.hide(); // Close the box
});
啊,是的,我猜你已经在两个(!)窗口加载了jQuery。
但是,这不会保存您的内容。你应该使用jQuery.ajax()方法解决这个问题。