如何从控制器访问片段中的片段? [英] How to access fragment in fragment from controller?
本文介绍了如何从控制器访问片段中的片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为cutleryCustomerSearch"的视图,其中包含(替换)一个片段:
<div th:replace="fragments/customerSearch::customerSearch"></div>
在这个片段中,我有一个表,我想通过 ajax 更新:
如何设置处理 ajax 请求的控制器方法的返回值?目前我有(不起作用):
return "cutleryCustomerSearch :: customerSearch/customersTable";
但是它并没有设置内容,它只是删除了表格.在我分割customerSearch"之前,它一直工作正常.
这里是我的ajax请求:
$.ajax({类型:'POST',缓存:假,网址:form.attr('action'),数据:form.serialize(),成功:功能(数据){$("#customersTable").html(data);}});
解决方案 其实很简单...
return "fragments/customerSearch::customersTable";
I have a view called "cutleryCustomerSearch" which includes (replace) a fragment:
<div id="content">
<div th:replace="fragments/customerSearch :: customerSearch"></div>
</div>
in this fragment i have a table which i like to update via ajax:
<table id="customersTable" th:fragment="customersTable">
How do I have to set the return of my controller method which handles the ajax request? At the moment i have (DOES NOT WORK):
return "cutleryCustomerSearch :: customerSearch/customersTable";
But it does not set the content, it just deletes the table.
It just works fine till i fragmentize the "customerSearch".
Here my ajax request:
$.ajax({
type : 'POST',
cache : false,
url : form.attr('action'),
data : form.serialize(),
success : function(data) {
$("#customersTable").html(data);
}
});
解决方案 Well it is so easy...
return "fragments/customerSearch :: customersTable";
这篇关于如何从控制器访问片段中的片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录
关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆