私は非常に単純なバックボーン js 構造を持っています。
var Step1View = Backbone.View.extend({
el:'.page',
render:function () {
var template = _.template($('#step1-template').html());
this.$el.html(template);
}
});
var step1View = new Step1View();
var Router = Backbone.Router.extend({
routes:{
"":"home"
}
});
var router = new Router;
router.on('route:home', function () {
step1View.render();
})
Backbone.history.start();
これはうまくいきますが、この単純な jquery 関数を呼び出すことができません。
$(document).ready(function() { $('.tip').tooltip(); });
アップデート
ここで男子生徒のエラー。Jquery onload 関数をルートに配置する必要があります。私はバックボーンに非常に慣れていないので、これがベストプラクティスかどうかわかりません。しかし、次の作品。
render:function () {
var that = this;
var savings = new Savings();
savings.fetch({
success:function () {
var template = _.template($('#step3-template').html(), {savings:savings.models});
that.$el.html(template);
// put your jquery good ness here
$('.tip').tooltip();
$(".step3-form").validate();
}
})
}