1

I'm working on a fieldtype with a lot of javascript and I use the following to get EE constants in the js:

$this->EE->javascript->set_global(array('THIRD_PARTY_THEME_URL' => URL_THIRD_THEMES));

This works well in the Control Panel, but not in Safecracker, which seems to reset all the EE js object.

Any idea how I can pass those kind of constants?

1 Answer 1

1

Not sure how to answer your specific questions, but I would use my Theme_loader class. It makes life really easy when it comes to loading JS and CSS assets within your module, and it works in Safecracker too. I typically like to extract all these type of components into stand-alone libraries to make code maintenance easier.

Once upon a time, EE didn't have those variables available so when they were released that caused a lot of code to be incompatible (or in need of upgrade). If devs would use an abstraction like this, they would have just only had to update 1 library for all their add-ons.

https://github.com/objectivehtml/Theme-Loader

1
  • Thanks Justin! I finally managed it by injecting my own global object in js. But I will definitely try your library, and try to unify all my addons with it.
    – pvledoux
    Apr 22, 2013 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.