I'm 99% finished integrating a wrapbootstrap theme into Drupal using Kalatheme! (minus Panels). But the custom js (which words perfectly outside of Drupal) is making drupal ornery.
I was getting a js "TypeError: $ is undefined" error in:
http://noname.com/sites/all/libraries/bootstrap/js/ace-elements.min.js:"
I surrounded the code in ace-elements.min.js, as per [ https://drupal.org/node/171213 ], with the following and fixed that error. But now I get a:
"TypeError: ace.settings is undefined" in:
http://noname.com/sites/all/libraries/bootstrap/js/ace.min.js:
What's the magic behind getting third-party custom js to play nice with Drupal? There appears to be just 3 custom js files, but fixing one seems to break the other.
(function ($) {
// Use jQuery with the shortcut:
console.log($.browser);
//code here
}(jQuery));Thanks.
Comments
Comment #1
pirog commentedIt really depends on the JS. You are going to want to wrap some as in the article you posted. Can you paste all the JS files here?
This all said... Kalatheme was built only entirely for panels so you are losing out on a lot of the easy to use functionality by opting out. Which is fine of course but thought i'd let you know :)
Comment #2
work77 commentedI'm really surprised that you haven't come across this error. It happens quite often with drupal and third-party js. Usually it's just one file so the closure fix works.
This js is minified, So I'm not sure if it's going to help, but these are the 3 files:
http://192.69.216.111/themes/preview/ace/assets/js/ace-elements.min.js
http://192.69.216.111/themes/preview/ace/assets/js/ace.min.js
http://192.69.216.111/themes/preview/ace/assets/js/ace-extra.min.js
Comment #3
pirog commentedHmmm, must be some confusion here.. we definitely have come across this error not just for wrapbootstrap/kalatheme adaption but in the adoption of many third party js things as you mentioned.
Usually the wrapping treatment you mentioned here https://drupal.org/node/171213 works. Harder to tell what to do with minified JS... do you have unminified at all?
Comment #4
labboy0276 commentedThis really isn't a Kalatheme issue. Sometimes when using JS with Drupal you have to do a little more than just the wrapper tags as previously mentioned.
I would suggest going here: http://jsbeautifier.org/ to unminify the JS yourself. You may need to also wrap this in something like:
OR maybe trying adding the wrapped js to your preprocess page with a hook instead of the .info file like:
Either way it really isnt a Kalatheme issue, but a Drupal "problem", read through the js page here again: https://drupal.org/node/304255 to try different solutions.
Good luck.
Comment #5
labboy0276 commented