Problem using jQuery

Topics: Themes
Feb 3, 2008 at 2:19 PM
Hi Guys,

I seem to be having problems using jQuery with blogengine, and as far as i can track it down, i beleive it is to do with the blog.js file. In this js file, the following function is defined.

function $(id)
{
return document.getElementById(id);
}

The problem here being that the $( ) syntax is used by jquery so is causing a conflict. Is there any chance this can be changed to something more unique?

Matt
Feb 4, 2008 at 4:19 AM
Matt

You are right, BlogEngine does define the $ function in their scripts but you cant change that without changing all of their scripts. Its not worth it, though. You will need to use the jQuery noConflict in your scripts.

var $j = jQuery.noConflict();

Then from that point on, you will use $j() to access jQuery instead of the normal $()

Obviously, you can make it whatever you want, i just choose $j
Feb 4, 2008 at 10:07 AM
Hmm, i already have a few scripts that i want to use so having looked through all the code, it was easier to change the blog code than my scripts.

Not a problem for me, i just thought what with jQuery being quite a big library in the comunnity, it would be best to make it as easy as possible to use what ever method you are comfortable with.

Cheers

Matt
Feb 4, 2008 at 2:51 PM
I think you are failing to see that jQuery isnt the only library, or JavaScript function for that matter, that uses the $() notation. Its a standard shorthand that all frameworks use as well as many other standalone function, as you can see in the blog.js file. jQuery included the noConflict feature for a reason. Next time BlogEngine.NET is updated, and you download it, you are going to need to go into blog.js (and potentially any new code they introduce) and make those same changes once again.

While it is obviously your own decision, I would strongly recommend using noConflict or using jQuery() notation.