I'm having a bit of a trouble here.
I'm using RequireJS to load my modules and dependencies.
I am trying to avoid polluting the global namespace, so I am using the following configuration as a starting point, to avoid defining $
or jQuery
in the global window object:
require.config({
map: {
'*': { 'jquery': 'jquery-no-conflict' },
'jquery-no-conflict': { 'jquery': 'jquery' }
},
shim: {
'jquery': { exports: 'jQuery' },
'angular': { exports: 'angular', deps: ['jquery'] }
// ...
}
});
The module jquery-no-conflict
would look like this:
define('jquery-no-conflict', ['jquery'], function (jQuery) {
return jQuery.noConflict(true);
});
This apparently solves the issue, but there is a problem.
I was not aware that there is some AngularJS behavior that is different wether jQuery is loaded or not, and apparently, this is done by inspecting the global namespace.
For instance, AngularJS $window
would be a wrapper of the native element window
if no jQuery is found or loaded, but it would be a wrapper of jQuery's $(window)
if jQuery is defined.
For some functionality on my website, I need the latter, but with this configuration, I am getting the former (because AngularJS does not seem to find jQuery);
Is there some way to inject my jQuery
module/variable to AngularJS and have it not inspect the global namespace?
As you can see my jquery
module is being exported, so RequireJS will give me a scoped variable when requesting it.
If this isn't possible, what would you do in my situation? What can be done to work around this?
If conventional jQuery globals cause problems, a custom window
property can be provided for jQuery with ng-jq
attrubute.
As of today Angular still relies on globals, jQuery isn't an exception.
I'm currently trying to display number series (for 2, 3, 4, 5, 6 and 7) in JavaScript. I was looking for the smallest number (x), which results in modulo = 1, if divided by 2, 3, 4, 5 and 6. If the ...
I'm currently trying to display number series (for 2, 3, 4, 5, 6 and 7) in JavaScript. I was looking for the smallest number (x), which results in modulo = 1, if divided by 2, 3, 4, 5 and 6. If the ...
I am working on a search function for a parent child structure with locations (city,suburb,street). I want to search for a street name and get the results but keeping the structure. The array ...
I am working on a search function for a parent child structure with locations (city,suburb,street). I want to search for a street name and get the results but keeping the structure. The array ...
It's silly, I know - every time I change environment I comment out and back my app's config factory. There must be a better way, is there? I though of checking the URL but this seems like a bad ...
It's silly, I know - every time I change environment I comment out and back my app's config factory. There must be a better way, is there? I though of checking the URL but this seems like a bad ...
When would I do <CustomComponent function = {this.FunctionName}/> instead of <CustomComponent function = {this.FunctionName.bind(this)}? React's documentation mentions that bind() solves ...
When would I do <CustomComponent function = {this.FunctionName}/> instead of <CustomComponent function = {this.FunctionName.bind(this)}? React's documentation mentions that bind() solves ...