I am working with jqDock on a DotNetNuke project. I ran jQuery.noConflict() and went through the jqDock.js file and changed all ‘$’ to ‘jQuery’ (though I don’t think it was necessary).
In this little bit of code I have an issue:
altImage : function(){
var alt = jQuery(this).attr('alt');
return (alt && alt.match(/\.(gif|jpg|jpeg|png)$/i)) ? alt : false;
} //end function altImage()
At the end of the regular expression there is a chunk that says $/i, My find/replace set this to jQuery. It broke the program. Is this because that ‘$’ symbol isn’t associated with jQuery there? Is it part of the Regular Expression? If so…what exactly is it saying?
The usual style to writing jQuery plugins would mean that one would not need to replace
$throughout the plugin. Most plugins are written such that the plugin code is surrounde by a self-invoking anonymous function that passes injQueryfor a parameter$such that$refers to the jQuery object inside of that function. Like soSo be careful when doing a naive find/replace.
As others have already mentioned, in the context of a regular expression,
$is used to match the end of the string.Finally, when using
$.noConflict(), you can assign thejQueryobject to a different alias and use that alias throughout the subsequent code. For example