0

以下是我尝试过但失败的两种方法:

//fails
$( $.Views('//home/home.ejs', {data:data}) ).appendTo('#home');

//fails
$( '//home/home.ejs', {data:data} ).appendTo('#home');
4

3 回答 3

0

我不熟悉 $.Views 但是,试试这个:

$( $.Views('//home/home.ejs', {data:data}) ).appendTo($('#home'));

或这个:

$( '//home/home.ejs', {data:data} ).appendTo($('#home'));

当您调用 appendTo 时,您必须传递一个 jQuery 选择器作为参数,而不仅仅是选择器字符串...

于 2012-02-07T22:30:45.573 回答
0

我发现了错误。它应该是 $.View 而不是 $.Views。但是第二种方法仍然行不通。

//works
$( $.View('//home/home.ejs', {data:data}) ).appendTo('#home');

//fails
$( '//home/home.ejs', {data:data} ).appendTo('#home');
于 2012-02-07T22:51:05.703 回答
0

JavascriptMVC 覆盖了一些 jQuery 的基本方法。其中之一是 .html,允许指定视图的路径而不是内部 html:

$("#home").html('//home/home.ejs', {data:data});

现在,如果你想追加, .append 方法会被相同的功能覆盖:

$("#home").append('//home/home.ejs', {data:data});

JSMVC 文档:http ://javascriptmvc.com/docs.html#!jQuery.fn.append

于 2012-02-08T21:01:09.757 回答