是否可以(如果可以,如何)将 jQuery 的appendTo 与$.Views 一起使用?
以下是我尝试过但失败的两种方法:
//fails
$( $.Views('//home/home.ejs', {data:data}) ).appendTo('#home');
//fails
$( '//home/home.ejs', {data:data} ).appendTo('#home');
Here are two ways I have tried and failed:
//fails
$( $.Views('//home/home.ejs', {data:data}) ).appendTo('#home');
//fails
$( '//home/home.ejs', {data:data} ).appendTo('#home');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不熟悉 $.Views 但是,试试这个:
或者这个:
当你调用appendTo时,你必须传递一个jQuery选择器作为参数,而不仅仅是选择器字符串......
I'm not familiar with $.Views but, try this:
or this:
when you are calling appendTo, you have to pass a jQuery Selector as the parameter, not only the selector string...
我发现了错误。它应该是 $.View 而不是 $.Views。但第二种方法还是不行。
I found the error. It should have been $.View and not $.Views. But the second way still won't work.
JavascriptMVC 重写了 jQuery 的一些基本方法。其中之一是 .html,允许指定视图的路径而不是内部 html:
现在,如果您想追加,则使用相同的功能覆盖 .append 方法:
JSMVC 文档: http://javascriptmvc.com/docs.html#!jQuery.fn.append
JavascriptMVC overrides some of jQuery's base methods. One of them is .html, allowing to specify a path to a view instead of the inner html:
Now, if you want to append, the .append method is overridden with the same functionality:
JSMVC Documentation: http://javascriptmvc.com/docs.html#!jQuery.fn.append