2014-10-01 3 views
0

Я хочу добавить файл с другой стороны Javascript.Meteor third party script doenst work

E.g. Когда я положил его в /public/test.js папку или /lib/test.js или /client/test.js

function testLoad(){ 

    alert("something"); 
} 

Я вижу сценарии получения загружены, но когда я пытаюсь запустить их через

if (Meteor.isClient) { 

    testLoad(); 

} 

Я получаю следующую ошибку

ReferenceError: testLoad is not defined

Что я упускаю?

ответ

2

Вы должны поместить файл в client/compatibility:

Some JavaScript libraries only work when placed in the client/compatibility subdirectory. Files in this directory are executed without being wrapped in a new variable scope. This means that each top-level var defines a global variable. In addition, these files are executed before other client-side JavaScript files.

http://docs.meteor.com/#structuringyourapp

Проблема заключается в том, что function functionName(){ <code> } обыкновение быть глобально определена функция (если вы поместите его в папку client/compatibility).

Смежные вопросы