Hola que tal, mi duda es la siguiente llevo varios días intentando crear una web con Backbone.js pero tengo errores, no se si me podrían ayudar :(
Código Javascript
:
Ver originalvar Modelo = {
Cupon: new Backbone.Model.extend(),
};
var Coleccion = {
Cupones: new Backbone.Collection.extend({
model: Modelo.Cupon,
url: 'scripts/assets/conectar.php',
parse: function(resp){
return resp;
},
}),
};
var Vista = {
CuponSolo: Backbone.View.extend({
className: 'cupon',
initialize: function() {
this.template = _.template($('#cuponsolo').val());
},
render: function() {
this.$el.html(this.template({cupon:this.model.toJSON()}));
return this;
},
}),
AppQpoint: Backbone.View.extend({
initialize: function(){
this.template = _.template($("#app-template").val());
this.collection = new Coleccion.Cupones();
this.collection.on('reset', this.MuestraCupones, this);
},
render: function(){
this.$el.html(this.template());
this.MuestraCupones();
return this;
},
MuestraCupones: function(){
this.$el.find('#todosCupones').empty();
var v = null;
this.collection.each(function(item, idx) {
v = new Vista.CuponSolo({model:item});
this.$el.find('#todosCupones').append(v.render().el);
}, this);
return this;
},
}),
};
$(document).ready(function() {
var vs = new Vista.AppQpoint();
vs.setElement($('#todosCupones')).render();
});
conectar.php
Código PHP:
$conexion = mysql_connect("**", "**", "***") or die ("Error al Conectar!");
mysql_query("SET NAMES 'utf8'");
mysql_select_db("clientes") or die ("Verifique la Base de Datos");
$consulta = mysql_query("SELECT * from cliente");
while($row=mysql_fetch_assoc($consulta)){
$output[]=$row;
}
print(json_encode($output));
mysql_close();
de verdad no se cual es el error en consola me marca
Uncaught TypeError: Object [object Object] has no method 'apply'
no se si me podrían ayudar de antemano gracias