如何使此表单获取用户的输入并再次呈现它 [英] How do I make this form take the input from the user and render it again

查看:67
本文介绍了如何使此表单获取用户的输入并再次呈现它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
    <head>

    <meta charset="UTF-8">

       <script src="jquery.js"></script>
      <script src="underscore.js" type="text/javascript"></script>
      <script src="backbone.js" type="text/javascript"></script>

      <script type="text/template" id="name">
        <form method="Post">Name:
        <input type="text" name="name" id="input" />
        <input type="submit" value="submit" id="form-submit" />


    </form>
    </script>

    <title>Form8</title>

    </head>
    <body>




FormModel = Backbone.Model.extend({

            defaults: {
                name: ''
            }
        });

        FormCollection = Backbone.Collection.extend({
            model: FormModel
        });


        FormView = Backbone.View.extend({
            el: '#View',
            events: {
                'click #form-submit': 'OnFormSubmit'
            },
            initialize: function () {


               this.render();

            },
            OnFormSubmit: function () {
                template1 = _.template($("#name").html());
            },

            render: function () {

               $(this.el).html($("#name").html());

                return this;
            }

        });
         var FormView = new FormView();

    </script>

推荐答案

#名)HTML())。
},

渲染: function (){
("#name").html()); }, render: function () {


this .el).html(
(this.el).html(


#名)HTML())。

返回 ;
}

});
var FormView = new FormView();

< / script>
("#name").html()); return this; } }); var FormView = new FormView(); </script>


这篇关于如何使此表单获取用户的输入并再次呈现它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆