MiroHibler / meteor-preloader

A Meteor "lazy-loader" for external .js and .css libraries
75 stars 3 forks source link

PreloadController is not defined #8

Closed perminder-klair closed 9 years ago

perminder-klair commented 9 years ago

Hello,

First of all, thanks for your awesome work!

I added package to my app, then when in route I added PreloadedController with: controller: PreloadController,

It returns this error: ReferenceError: PreloadController is not defined

Any solution or suggestion?

Many thanks!!

MiroHibler commented 9 years ago

I think there's a bug in Iron.Router, not sure tho...

Anyway, as a workaround, put apostrophes around the PreloadController:

controller: 'PreloadController',

That should do it.

perminder-klair commented 9 years ago

great! many thanks @MiroHibler !

perminder-klair commented 9 years ago

Just tried with apostrophes still same issue.

Please suggest.

MiroHibler commented 9 years ago

Could you post some code?

perminder-klair commented 9 years ago

Sure, here it is: https://codio.com/perminder-klair/Meteor-Preloader

try to run, and it gives this error: Error: RouteController 'PreloadController' is not defined.

Route is located at: /lib/router/home.js

MiroHibler commented 9 years ago

Oh, I see - as with SEO package, PreloadController is only available on client side, so you should isolate it by defining your routes in a client side file (i.e. /client/lib/router/home.js).

One of the next versions will take care of that.

perminder-klair commented 9 years ago

Thanks, Just tried to move routes to client, same issue.

MiroHibler commented 9 years ago

Where do you get the error ReferenceError: PreloadController is not defined, in server console or in a browser console?

perminder-klair commented 9 years ago

Hi @MiroHibler , i get this error at both places server and browser.

MiroHibler commented 9 years ago

Make sure that you add the package with:

meteor add miro:preloader

then check it out with:

meteor list

It should appear in the list of active packages.

MiroHibler commented 9 years ago

Any luck?

perminder-klair commented 9 years ago

Hello @MiroHibler ,

I just checked with meteor list it gives following result: miro:preloader 1.1.0 A synchronous/asynchronous Meteor preloader for external .js and .css libraries

But when I try to run app, it still gives same error, this is code I have in my route:

Router.route('/', {
    name: 'home',
    controller: 'PreloadController',
    //fastRender: true,
    onAfterAction: function () {
        //var post;
        // The SEO object is only available on the client.
        // Return if you define your routes on the server, too.
        if (!Meteor.isClient) {
            return;
        }
        SEO.set({
            title: 'Home - ' + Meteor.App.NAME,
            meta: {
                'description': 'Welcome to my site.'
            }
        });
    }
});

Error is:

Error: RouteController 'PreloadController' is not defined.    

Code is available at: https://codio.com/perminder-klair/Meteor-Preloader

Feel free to fork or zip it and try running locally to debug.

MiroHibler commented 9 years ago

According to the sample code you provided, you're still loading PreloadController on both server- and client-side, which is not yet supported. It works only client-side.

As a quick workaround, move your /lib/router folder to /client/lib/router folder - that way you'll ensure PreloadController is loaded only client-side.

perminder-klair commented 9 years ago

@MiroHibler thanks, works under client directory.

Thanks for support! looking forward until support on server side.

Thanks again!

MiroHibler commented 9 years ago

You're welcome! :)

Happy coding!