BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
855 stars 130 forks source link

JsViews with Browserify #337

Closed ViktorHofer closed 8 years ago

ViktorHofer commented 8 years ago

Hi Boris and thanks for your GREAT work,

I'm currently facing an issue where I can't require jsviews in combination with Browserify.

I do it like this:

var $ = require('jquery');
require('../node_modules/jsrender/jsrender.js')($);
require('../node_modules/jsviews/jsviews.js')($);

JsRender require works really well! But jsviews require fails with the following error: "Uncaught TypeError: Cannot read property 'advanced' of undefined". So $subSettings is undefined but I don't know why... More precisely the error occures in these lines of your library:

$sub.advSet = function() { // refresh advanced settings
        global._jsv = $subSettings.advanced._jsv
            ? { // create global _jsv, for accessing views, etc
                    cbBindings: cbBindingsStore
                }
            : undefined; // In IE8 cannot do delete global._jsv
    };

Jquery is included and $ is not undefined. Loading jQuery globally isn't possible in my application...

Thanks for your help and your great work :+1:

ViktorHofer commented 8 years ago

Boris helped me via mail, the solution was that I included jsrender AND jsviews but jsviews already includes jsrender :dancers: