Tema: Backbone
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/08/2013, 04:10
djmkmix
 
Fecha de Ingreso: abril-2011
Ubicación: Baja California sur
Mensajes: 39
Antigüedad: 13 años
Puntos: 0
Pregunta Backbone

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 original
  1. var Modelo = {
  2.             Cupon: new Backbone.Model.extend(),
  3.         };
  4.  
  5.         var Coleccion = {
  6.             Cupones: new Backbone.Collection.extend({
  7.                 model: Modelo.Cupon,
  8.                 url: 'scripts/assets/conectar.php',
  9.                 parse: function(resp){
  10.                     return resp;
  11.                 },
  12.  
  13.             }),
  14.         };
  15.  
  16.  
  17.         var Vista = {
  18.             CuponSolo: Backbone.View.extend({
  19.                 className: 'cupon',
  20.  
  21.                 initialize: function() {
  22.                     this.template = _.template($('#cuponsolo').val());
  23.                 },
  24.  
  25.                 render: function() {
  26.                     this.$el.html(this.template({cupon:this.model.toJSON()}));
  27.                     return this;
  28.                 },
  29.             }),
  30.  
  31.             AppQpoint: Backbone.View.extend({
  32.  
  33.                 initialize: function(){
  34.                     this.template = _.template($("#app-template").val());
  35.                     this.collection = new Coleccion.Cupones();
  36.                     this.collection.on('reset', this.MuestraCupones, this);
  37.                 },
  38.  
  39.                 render: function(){
  40.                     this.$el.html(this.template());
  41.                     this.MuestraCupones();
  42.                     return this;
  43.                 },
  44.  
  45.                 MuestraCupones: function(){
  46.                     this.$el.find('#todosCupones').empty();
  47.                     var v = null;
  48.                     this.collection.each(function(item, idx) {
  49.                         v = new Vista.CuponSolo({model:item});
  50.                         this.$el.find('#todosCupones').append(v.render().el);
  51.                     }, this);
  52.                     return this;
  53.  
  54.                 },
  55.  
  56.  
  57.  
  58.             }),
  59.         };
  60.  
  61.  
  62. $(document).ready(function() {
  63.     var vs = new Vista.AppQpoint();
  64.     vs.setElement($('#todosCupones')).render();
  65. });


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