Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php编辑页面在shadowbox中启动,需要刷新父页面点击保存按钮_Php_Jquery - Fatal编程技术网

Php编辑页面在shadowbox中启动,需要刷新父页面点击保存按钮

Php编辑页面在shadowbox中启动,需要刷新父页面点击保存按钮,php,jquery,Php,Jquery,我想知道解决这个问题的最好方法是使用PHP还是使用jQuery?不确定当用户在编辑窗口中单击“保存”并提交更改时,如何最好地结合刷新父页面的数据。启动窗口的代码如下所示: <a href=\"/" . $Controller->Organization . "/community/edit_entry/?entry_id=" . $comEntry->getID() . "\" class=\"lightview\" title=\":: :: width:600, heigh

我想知道解决这个问题的最好方法是使用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>


您可以利用jQuery并设置一个
onclick()
事件处理程序,在单击保存按钮时刷新页面。此外,如果需要,您可以应用表单验证,并且只有在满足所有要求时才刷新页面。在不知道项目具体需要什么的情况下,您也可以通过AJAX完成所有操作,而不重新加载页面。

正如您在代码示例(“编辑”窗口)中所看到的,shadowbox片段使用
window.parent
访问parents窗口元素以关闭该框

您必须编写自己的JavaScript并向submit按钮添加一个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()方法来解决这个问题。

这实际上是一个lightview窗口,而不是Shadowbox。这个网站上的ajax已经过时了,不容易更新。因此,目前最好的解决办法是尽可能避免使用它。我需要编辑这篇文章,因为这个窗口实际上是一个lightview窗口,而不是阴影框,正如你从关闭按钮代码中看到的那样。所以我想我基本上需要一些像…只有…你知道…代码可以工作。