2014-04-22 7 views
0

문제가 있습니다 - 양식의 데이터를 데이터베이스에 넣어야합니다 ... 백본 사용법이 있습니다! 어떻게 그럴 수 있습니까? 내 scrips 및 HTML 작성해야합니까? 내 모음입니다 :백본의 입력 필드에서 데이터를 저장하는 방법은 무엇입니까?

store: function(e) 
{ 
    e.preventDefault(); 

    //select each input, select and textarea within this views $el 
    _.each(this.$('input, select, textarea'), function(input) 
    { 
     //you input name attribute to set the correct model attribute. 
     this.model.set(input.name, input.value); 
    }, this); 

    //new model attributes from the form are now available and ready to be synced 
    //with the server. 
    console.log(this.model.toJSON()); 
} 

확인이 JsFiddle Demo :

define([ 
     "underscore", 
     "backbone", 
     "jquery" 

    ], 
    function(_, Backbone, $) { 
     return Backbone.Collection.extend({ 

      url: '/users/all' //route for get ALL users in DB 
     }); 
    }); 

답변

0

당신은 단순히 당신의 HTML을 반복은 사용자 안타 전송할 때마다 형성하는 방법을 만들 수 있습니다.

관련 문제