Can a script be included after the Model is initialized?

1 view
Skip to first unread message

Confucius

unread,
Jan 25, 2010, 10:29:52 AM1/25/10
to JavaScriptMVC
I'm re-engineering an app in JMVC which had some global config
variables (ie: locale, propertyCode, etc), so assume I should make an
AJAX call and set any init data like this in the Model. In the case of
'locale' though, I'm using a JMVC 1.5-style translation plugin with a
translations file, which is included (by app init) before
'myapp.js' (app Model) and 'myapp_controller.js' (app Controller).

So I need to pass the locale into 'include.translation()', but it gets
included before Model is initialized, which means I can't pass
'Myapp.getLocale()' into 'include.translation()' because it's not
initialized yet.

Can the translations file be included after the Model and Controller
have initialized?

Confucius

unread,
Jan 25, 2010, 2:56:36 PM1/25/10
to JavaScriptMVC
I assume that the answer to this is 'no, includes have to be done
before objects are initialized', so since 'locale' is available in the
JSP request, I just added the translation file 'script' tag into the
HTML container page, rather than having it written dynamically by
'init.js'.

<script type="text/javascript" src="/reportsTier/jsmvc/views/i18n/<
%= request.getParameter("locale") %>.js"></script>

This works as long as it's at the bottom of the page, after all the
JMVC stuff.

Reply all
Reply to author
Forward
0 new messages