Backbone.js 获得价值的形式!文本插件-主干

Backbone.js 获得价值的形式!文本插件-主干,backbone.js,requirejs,Backbone.js,Requirejs,我在用!require.js的文本插件将主干项目的模板分离到html文件中 以下是html文件: <form> <table style="padding-left:10px;"> <tr valign="top"> <td> <table> <tr> <td>Enter the service

我在用!
require.js的文本插件
主干
项目的模板分离到html文件中

以下是
html
文件:

<form>
<table style="padding-left:10px;">
    <tr valign="top">
        <td>
            <table>
                <tr>
                    <td>Enter the service number : <br /></td>
                </tr>
                <tr>
                    <td>
                        <input type="text" id="servicenumber" style="height:24px;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" id="searchservice" value="Search" class="btn"/>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</form>
表单在我的网页中查看,但是当我查看源代码时,没有表单,所以
console.log(“这是”+$(“#服务编号”).val()未显示在我的控制台中。有什么想法吗


感谢您的高级支持。

您必须指定视图的
el
元素:

var serviceTagLookUpView = Backbone.View.extend({
  el: '#page', // give it an existing div in you page
  initialize : function(){
  },
  ...


这里有一个例子,当你评论
el:“#页面”时,
你的视图不会被呈现。

你调用了
serviceTagLookUpView.render()
方法吗?@RidaBENHAMMANE:我在路由器中调用了它。你的html页面是否包含
?是的,当我在浏览器中查看源代码时,div是存在的。我更新了我的答案,让我知道你是否有问题。将html模板转换为字符串?是的,这就是require.js!文本插件为你做的,除了他从服务器加载它。
var serviceTagLookUpView = Backbone.View.extend({
  el: '#page', // give it an existing div in you page
  initialize : function(){
  },
  ...