Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
HTML
<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>

JavaScript
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>
Posted
Comments
Sinisa Hajnal 16-Jan-15 2:26am    
What have you tried? What part of the code doesn't work? In what way? What do you expect as output?

1 solution

var FormView = new FormView({
model: model,
Var1 : value
});
FormView.render();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900