set form element values

瀏覽次數:193 次
跳到第一則未讀訊息

me moi

未讀,
2013年12月5日 下午4:05:412013/12/5
收件者:backbon...@googlegroups.com

with this code :

    var modform = new Backbone.Form({

//Schema

schema: {

id:         'Number',

name:       'Text',

password:   'Password'

},

 

//Data to populate the form with

data: {

id: 123,

name: 'Rod Kimble',

password: 'cool beans'

}

}).render();

var html = modform.$el.html();

console.log(html);


I get  :


<fieldset data-fields=""> <div> <label for="id">Id</label> <div> <span data-editor=""><input id="id" name="id" type="number" step="any"></span> <div data-error=""></div> <div></div> </div> </div><div> <label for="name">Name</label> <div> <span data-editor=""><input id="name" name="name" type="text"></span> <div data-error=""></div> <div></div> </div> </div><div> <label for="password">Password</label> <div> <span data-editor=""><input id="password" name="password" type="password"></span> <div data-error=""></div> <div></div> </div> </div></fieldset>


None of the form elements gets values?

Any idea?

Thanks for your help

me moi

未讀,
2013年12月5日 下午4:16:592013/12/5
收件者:backbon...@googlegroups.com

me moi

未讀,
2013年12月6日 清晨5:14:442013/12/6
收件者:backbon...@googlegroups.com
Ok I found out that appending the dom element does insert values : 

$('body').append(modform.el);

me moi

未讀,
2013年12月6日 清晨5:32:102013/12/6
收件者:backbon...@googlegroups.com
backbone-form is very nice in fact, it works great.

It even works with html 5 new elements. By the way you could add :

/**
 * Color editor
 */
Backbone.Form.editors.Color = Backbone.Form.editors.Text.extend({
    initialize: function (options) {
        Backbone.Form.editors.Text.prototype.initialize.call(this, options);
        this.$el.attr('type', 'color');
    }
});

It works nicely on chrome :


 Thanks
回覆所有人
回覆作者
轉寄
0 則新訊息