define(["underscore", "backbone", "jquery"],
function(_, Backbone, $) {
return Backbone.Model.extend({
urlRoot: "/adduser",
defaults: {
"email": "",
"f_name": "",
"id_role": 0,
"l_name": "",
"login": "",
"password": "",
"status": 1
}
});
});
define([
"underscore",
"backbone",
"jquery",
"text!pages/RestaurantPage/templates/AdminTemplate.html",
"pages/RestaurantPage/models/User"
],
function(_, Backbone, $, AdminTemplate, User) {
return Backbone.View.extend({
events: {
events: {
'submit #new_user': 'save'
}
},
initialize: function() {
this.collection = new User();
this.collection.on("change", this.collection.save());
},
el: $('#content'),
save: function(e) {
alert('ok"');
var userInfo = {
email: this.$('#email').val(),
l_name: this.$('#l_name').val(),
f_name: this.$('#f_name').val(),
login: this.$('#login').val(),
password: this.$('#password').val(),
id_role: this.$('#id_role').val(),
status: this.$('#status').val()
};
this.collection.save(userInfo);
},
render: function() {
this.$el.html(AdminTemplate);
}
});
});
define([
"underscore",
"backbone",
"jquery",
"text!pages/RestaurantPage/templates/AdminTemplate.html",
"pages/RestaurantPage/models/User"
],
function(_, Backbone, $, AdminTemplate, User) {
return Backbone.View.extend({
el: $('#content'),
events: {
'submit #new_user': 'save'
},
initialize: function() {
this.model = new User();
},
render: function() {
this.$el.html(AdminTemplate);
}
save: function(e) {
alert('ok"');
var userInfo = {};
_.each($('#new_user')[0], function(el) {
userInfo[el.id] = el.value;
});
this.model.save(userInfo,{
success: function(res){console.log('succes'),
error: function(res){console.dir(res)}
}});
},
});
});
define(["underscore", "backbone"],
function(_, Backbone) {
return Backbone.Model.extend({
url: function () {
return "/adduser";
},
defaults: {
"email": "",
"f_name": "",
"id_role": 0,
"l_name": "",
"login": "",
"password": "",
"status": 1
}
});
});