如何在表达式引擎中使用带有 safecracker 的 fancybox 来关闭和更新父级

发布于 2024-12-28 18:02:42 字数 2541 浏览 4 评论 0原文

为了管理大约 800 个条目的列表,我使用带有下拉列表的表单来过滤掉各种自定义字段,包括两个自定义日期。结果使用表达式引擎动态参数进行过滤。

{exp:channel:entries 
  channel="jobb_ticket" 
  search:display="published|updated|delivered" 
  status="Open|Closed" 
  limit="9999" 
  dynamic_parameters="search:namn|search:produkt|search:kund|search:producent|search:materialdag|search:utgivningsdag" orderby="materialdag|utgivningsdag" 
  date_field="materialdag" 
  date_field_start="<? if(!empty($_POST['startdate'])){echo date('Y-m-d H:i', $_POST['startdate']);} ?>" 
  date_field_stop="<? if(!empty($_POST['startdate'])){echo date('Y-m-d H:i', $_POST['startdate'] + 604799);} ?>" 
  sort="asc|asc" 
}

过滤后的列表在每行后面包含一个提交按钮,以便能够编辑一些自定义字段,链接到包含保险箱表单的 fancybox。

在 html 中:

<div class="col_btn_registrera"><a class="registrera_produkt fancybox.ajax" href="{site_url}client/client_register_ajax/index_thewineagency/{entry_id}"><input type="submit" name="" value="Registrera" /></a></div>

在 header 中

$('.registrera_produkt').fancybox({
Width  : 340,
Height  : 100,
autoDimensions : false
}); 

在 fancybox 中,safecracker 表单中的

<html>
<head>
[removed]
    $(document).ready(function(){
            $('#publishForm').ajaxForm({
                    dataType: 'json',
                    success: function(data) {
                            if (data.success) {                                                                   
                            } else {
                                    alert('Failed with the following errors: '+data.errors.join(', '));
                            }
                    }
            });
    });
    $('#publishForm').submit(function(){
     $.fancybox.close();
     $(parent.document)[0].location.reload(true);
     return false;
    });
[removed]
<link href="{path=css/_ee_saef_css}" type="text/css" rel="stylesheet" media="screen">
<link href="{site_url}css/gridlocker.css" rel="stylesheet" type="text/css">
</head>
<body>
{exp:safecracker include_jquery="no" channel="jobb_ticket" entry_id="{last_segment}"}
<input type="text" name="produkt" id="produkt" value="{produkt}">br>
<input type="submit" name="submit_button" id="submit_button" value="Uppdatera">
{/exp:safecracker}
</body>
</html> 

记录确实会更新,fancybox 窗口确实会关闭父页面,但不会更新。

如何在提交后更新父页面但不重置过滤结果? 或者如何使用上次使用的表单值启动新搜索?

有更好的方法吗?

恳请

拉尔夫帮助

To manage a list of about 800 entries i use a form with droplists to filter out various custom fields, including two custom dates. Result is filtered with expressionengines dynamic_parameters.

{exp:channel:entries 
  channel="jobb_ticket" 
  search:display="published|updated|delivered" 
  status="Open|Closed" 
  limit="9999" 
  dynamic_parameters="search:namn|search:produkt|search:kund|search:producent|search:materialdag|search:utgivningsdag" orderby="materialdag|utgivningsdag" 
  date_field="materialdag" 
  date_field_start="<? if(!empty($_POST['startdate'])){echo date('Y-m-d H:i', $_POST['startdate']);} ?>" 
  date_field_stop="<? if(!empty($_POST['startdate'])){echo date('Y-m-d H:i', $_POST['startdate'] + 604799);} ?>" 
  sort="asc|asc" 
}

The filtered list contains after each row a submit button, to be able to edit some of the custom fields, linked to a fancybox containing a safecracker form.

in the html:

<div class="col_btn_registrera"><a class="registrera_produkt fancybox.ajax" href="{site_url}client/client_register_ajax/index_thewineagency/{entry_id}"><input type="submit" name="" value="Registrera" /></a></div>

In the header

$('.registrera_produkt').fancybox({
Width  : 340,
Height  : 100,
autoDimensions : false
}); 

In the fancybox the safecracker form

<html>
<head>
[removed]
    $(document).ready(function(){
            $('#publishForm').ajaxForm({
                    dataType: 'json',
                    success: function(data) {
                            if (data.success) {                                                                   
                            } else {
                                    alert('Failed with the following errors: '+data.errors.join(', '));
                            }
                    }
            });
    });
    $('#publishForm').submit(function(){
     $.fancybox.close();
     $(parent.document)[0].location.reload(true);
     return false;
    });
[removed]
<link href="{path=css/_ee_saef_css}" type="text/css" rel="stylesheet" media="screen">
<link href="{site_url}css/gridlocker.css" rel="stylesheet" type="text/css">
</head>
<body>
{exp:safecracker include_jquery="no" channel="jobb_ticket" entry_id="{last_segment}"}
<input type="text" name="produkt" id="produkt" value="{produkt}">br>
<input type="submit" name="submit_button" id="submit_button" value="Uppdatera">
{/exp:safecracker}
</body>
</html> 

the record does get updated and the fancybox window does close the parent page however does not update.

How do i update the parent page after submit but without resetting the filtered result?
or how do i initiate a new search with last used form values?

Is there a better way of doing it?

kindly asking for help

ralph

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独守阴晴ぅ圆缺 2025-01-04 18:02:42

您可能必须进行 AJAX 调用并检索更新的列表并替换父页面上的列表。

You would probably have to make an AJAX call and retrieve the updated list and replace the list that was on the parent page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文