jmpressjs / jmpress.js

A jQuery plugin to build a website on the infinite canvas
http://jmpressjs.github.com/jmpress.js
1.5k stars 237 forks source link

Not an issue. Just fun with jmpress.js and backbone.js #124

Closed rexdtripod closed 10 years ago

rexdtripod commented 11 years ago

No good reason to do this at all but I just like to tinker and break things and see how they work :)

I have a backbone.marionette app with require.js handling script loading and dependencies and handlebars.js handling templating. I thought to myself "no way jmpress.js will work in this context". So, of course, I had to try. I used the simple example (4 slides).

I got close. jmpress library loads and my backbone view renders the handlebars template containing the 4 slides to a div id=simple. No errors. I can see the first slide there but it doesn't look active. Hitting the right arrow button to navigate generates the error "Cannot read property 'next' of null" at jmpress.js line 1311. Looks like "stepData" is null at that juncture.

Again, just like to learn how stuff works. I'm thinking the fact that the backbone render is off DOM and then content is added after the initial page load somehow creates a problem. The resultant html in the browser looks correct when I view browser source. It's 4 divs inside a "simple" div. My backbone view is below.

var JmpressView = Backbone.Marionette.ItemView.extend({

template: Handlebars.compile(
        '<div id="home" class="step">' +
            '<p>Hello! My name is jmpress.js...</p>' +
        '</div>' +
        '<div class="step" data-x="1000">' +
            '<p>and this is a really simple demo.</p>' +
        '</div>' +
        '<div class="step" data-x="2000">' + 
            '<p>You might think it is boring...</p>' +
        '</div>' +
        '<div class="step" data-x="3000">' +
            '<p>but that is the point. This is a simple example.</p>' +
        '</div>' 
),

render: function () {
    this.el = $(this.template());
    return this;
}

});

jmpress