jquery中的MVC,来自模型的多个数据请求但需要单个回调
基本上,设置几乎与 [[ 多个 json 请求的一个回调 相同]],但我认为这个解决方案太老套了,它应该可以在 MVC 中以更干净的方式处理。
“Tickets”和“People”是不同的模型,每个模型都有一个 getAll 方法。我需要使用两个 getAll 方法中的数据初始化一个插件。它们可能是 ajax 请求,但我想让插件调用者忽略它。我想不出办法,但我没有 MVC 经验,有什么帮助吗?或者我应该如何清理它以使mvc更干净?
我正在尝试追求类似 this 的东西。谢谢!!
Basically the setup is almost the same as [[ One callback for multiple json requests ]], but I think the solution is too hacky and that it should be handle-able in a cleaner way in MVC.
'Tickets' and 'People' are distinct models and there is a getAll method to each. I need to initialize a plugin with data from both getAll methods. They could be ajax requests, but I want to make it oblivious to the plugin caller. I can't think of a way, but I have no experience in MVC, any help guys? Or how should I clean it so that the mvc is cleaner?
I am trying to go after something like this. Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保
.getAll
返回一个$.Deferred
对象,以便您可以抽象出加载模型是否是异步的。Make sure that
.getAll
returns a$.Deferred
object so you can abstract away whether loading your models is asynchronous or not.