“片面观点” “容器”的最佳实践; div?

发布于 2024-08-30 20:44:47 字数 580 浏览 2 评论 0原文

处理部分视图的 html 标记的“最佳”方法是什么? (也使用 AJAX 刷新) 我遇到的最大问题是在哪里放置“容器”div...

考虑使用 母版页 和部分视图。
(class="" 可以与 id="" 互换,具体取决于部分是否保证是唯一的,但这对我认为的问题并不重要)

母版页:

<div id="place1" class="placeholder">
<!-- render partial -->
</div>

部分:

<div id="partial1" class="partial">
<!-- content -->
</div>

我觉得有些事情没有做对。但是,我无法删除母版页中的 div,因为我需要它来“封装”来自 AJAX 部分更新的响应。而且我也无法将部分中的 div 移动到母版页,因为这需要将“部分”信息移动到母版页...

你如何处理这个?

What is the 'best' way to handle the html markup for partial views? (which are also refreshed using AJAX) The biggest issue I run into is where to place the 'container' div...

Consider having a masterpage and a partial view.
(class="" could be interchanged with id="" depending if the partial is guaranteed to be unique, however this isn't really important to the issue i think)

Masterpage:

<div id="place1" class="placeholder">
<!-- render partial -->
</div>

Partial:

<div id="partial1" class="partial">
<!-- content -->
</div>

I feel that something isn't being done right. However I cannot remove the div in the masterpage, because I need that to 'encapsulate' the response from AJAX partial updates. And also I cannot move the div in the partial to the masterpage, because that would require to move 'partial' info to the masterpage...

How do you handle this?

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

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

发布评论

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

评论(1

凝望流年 2024-09-06 20:44:47

我想说的是,它对这里发生的事情进行语义描述,为样式和脚本编写提供良好的钩子,并且就针对未来使用和更改的总体鲁棒性而言,使用这两个 div 是最好的方法。

I would say that it terms of the semantic description of what is happening here, of providing good hooks for styling and scripting, and also in terms of general robustness against future uses and changes, that using both divs is the best way to go.

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