Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/07/2016, 11:23
gfcarbonell
 
Fecha de Ingreso: abril-2016
Mensajes: 19
Antigüedad: 8 años
Puntos: 0
Respuesta: Envio un POST usando backbone y server (python-django) no lo recibe

var Backbone = require("backbone");
var $ = require("jquery");
var _ = require("underscore");

var Pais = require("../models/pais");
var Paises = require("../collections/paises");

class PaisNewView extends Backbone.View
{
initialize()
{
this.template = _.template($("#form-submit-pais").html()); //mi template donde esta el formulario
this.render();
}
events()
{
return {"click #submit-pais": "submit_add", };
}
submit_add(events)
{
events.preventDefault();
var pais = new Pais();
pais.nombre = $("#id_nombre").val();
pais.codigo_postal = $("#id_codigo_postal").val();
console.log(pais);
pais.save(null, {
success: function (model, response) {
console.log("success");
},
error: function (model, response) {
console.log(model);
console.log(response);
}
});

events.currentTarget.checkValidity();
return false;
}
render ()
{
this.$el.html(this.template());
return this;
}
}

module.exports = PaisNewView;