Awea
Awea

Reputation: 3173

Backbone.js and RequireJS add JQuery plugins

I started my first backbone.js app today and I meet a first problem. I use RequireJS, Backbone and Underscore.

So I wrote this :

main.js

require.config({
  paths: {
    jquery: 'libs/jquery/jquery-min',
    underscore: 'libs/underscore/underscore-min',
    backbone: 'libs/backbone/backbone-optamd3-min',
    text: 'libs/require/text',
    jticker: 'libs/jquery/jquery.jticker'
  }

});

require([
  'app'
], function(App){
  App.initialize();
});

app.js

define([
  'jquery',
  'underscore',
  'backbone',
  'router', // Request router.js
], function($, _, Backbone, Router){
  var initialize = function(){
    Router.initialize();
  }

  return {
    initialize: initialize
  };
});

view app.js call by the default route

define([
  'jquery',
  'underscore', 
  'backbone',
  'jticker'
  ], function($, _, Backbone, jticker){
  var AppView = Backbone.View.extend({

    el: $("body"),

    initialize: function() {
      _.bindAll(this, 'render');
    },

    render: function() {
        $(this.el).append('bla');
        $(".dialogue").jticker();
    },

  });
  return AppView;
});

And i have this problem how can I use jticker in my view ? Actually it produce an error without details :

$(
[Stopper sur une erreur]    

$(".dialogue").jticker();

Upvotes: 0

Views: 899

Answers (1)

3logy
3logy

Reputation: 2712

Have you try to use jticker() after the rendering? because i have the same problems actually in one of my project! If you wait that the DOM completly loaded and then set ".dialogue" with jticker()... just my 5 cents

Upvotes: 2

Related Questions