Lance Long Gold Membership
 Nuke Wiz Posts:132


 |
| 12/13/2007 3:17 PM |
|
Scott,
I'm using jQuery for other functions on the site outside simple gallery and property agent. I can't test this but do you know if one can load two includes simultaneously?
Alternatively, could we tell modules where common files are?
The amount of Javascript an average DNN site loads is becoming a thorn in my side.
Lance |
|
|
|
|
Scott McCulloch Administrators
 Nuke Master Posts:12596


 |
| 12/13/2007 5:34 PM |
|
I'm not sure about loading 2, it should just use one because it's a function that calls the jQuery library. I could add options for common files, it would be nice if the core support something for this. |
|
Scott McCulloch Site Administrator |
|
|
Lance Long Gold Membership
 Nuke Wiz Posts:132


 |
| 12/13/2007 5:52 PM |
|
[rant]
I agree!
I have been wanting better control of the head content and support files in general. I make use of Pageblaster but it doesn't run on postback notices. The only reliable way is to write .Net into the skin but then you can't added script blocks or things like IE conditional CSS.
I would love it if instances, portals, modules, skins, containers all registered their support files to the same object which would handle duplications at request time.
It could also load the files dynamically client side so a) the DOM loads quicker and b) cell phone etc. don't download files they can't use.
[/rant]
I did some brief testing and as jquery is a self initializing library there were problems with two scripts on the same page.
Libraries like jquery and prototype really do belong in a shared resource folder. Custom js should stay in the DecktopModules folder but then you have install issues.
I don't really know how to handle it; all my thoughts feel cumbersome and weak. |
|
|
|
|
jon winters Gold Membership
 Nuke Active Member Posts:35

 |
| 12/14/2007 5:06 AM |
|
The way I handle this is to add the the jquery.js to the head by using the following code in my skin {script runat="server"} Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init Dim oCSS As Control = Me.Page.FindControl("CSS") If Not oCSS Is Nothing Then 'add a script reference for Javascript to the head section Dim oLink As New HtmlGenericControl("script") oLink.Attributes("language") = "javascript" oLink.Attributes("type") = "text/javascript" oLink.Attributes("src") = SkinPath & "js/jquery-1.2.1.pack.js" oCSS.Controls.AddAt(0, oLink) End If End Sub {/script} Then I put the individual library in the Module Settings. I don't know if this is the best way to handle it, but it works for me. Jon |
|
|
|
|
Lance Long Gold Membership
 Nuke Wiz Posts:132


 |
| 12/15/2007 5:15 PM |
|
Jon,
I use this method extensively too. Problem is there are no controls over what you can or can't load so that conflicts and duplications don't occur. It's as important to me that I remove assets as add them.
It comes down to modules needing manual overrides for common assets.
Lance
...
I just re-read your post and not sure I follow now. Are you talking about solving multiple copies? Is this how you write modules or write skins?
|
|
|
|
|
caroig Gold Membership
 Nuke Master Posts:279

 |
| 2/18/2008 1:44 PM |
|
Hi Scott,
Have been able to give this any more thought?
I'm using jQuery more and more and there is hardly a page where it doesn't appear now. I've run into a problems with simple gallery (and property agent) - I've updated to the latest JQuery Library 1.2.2 and these modules (at least versions I'm currently running are on 1.2.1).
I'm with you wholeheartedly that this is a big gap in the DNN core, but in the interim do you see some sort of solution?
I'd guess that the best solution from your point is that your load can be optionally switched off and then the users can fiddle away at their own risk.
Lance,
I'm about to install PageBlaster and I think that with the latest version I can identify the Ventrian js files and remove them.
I'm with you that some module level overrides are needed until the DNN team come up with something more strategic.
|
|
|
|
|
Lance Long Gold Membership
 Nuke Wiz Posts:132


 |
| 2/18/2008 1:58 PM |
|
Caroig, Pageblaster is an option but adds more complexity than there should be. It also doesn't run 100% of the time (like when you choose to " Launch Links" or some admin screens) so you will have the conflicts again in those cases. |
|
|
|
|
Scott McCulloch Administrators
 Nuke Master Posts:12596


 |
| 2/18/2008 2:06 PM |
|
If you include 2 instances of jQuery on the same page, it will cause issues. I'll be releasing a patch with some more advanced checking for simple gallery / property agent and an option in each module to disable including the jQuery library for that instance. This will allow advanced users to tweak as needed. |
|
Scott McCulloch Site Administrator |
|
|
caroig Gold Membership
 Nuke Master Posts:279

 |
| 2/18/2008 2:12 PM |
|
Great stuff. Thanks Scott |
|
|
|
|
Lance Long Gold Membership
 Nuke Wiz Posts:132


 |
| 2/23/2008 4:59 PM |
|
FYI Any Name jQuery jQuery has taken a big step to become the first major JavaScript library completely capable of renaming itself. Previously, functionality was provided to rename the oft-used ‘$’ shortcut for ‘jQuery’ - but now you can also rename both ‘$’ and ‘jQuery’. This allows for two fantastic results: * You can now include multiple versions of jQuery, simultaneously, on the same page. * You can now embed jQuery into the namespaces of other objects and libraries, for example: // With the Dojo Toolkit dojo.jquery = jQuery.noConflict(true); dojo.jquery(”#elem div”).slideDown(”slow”); // or with Yahoo UI YAHOO.query = jQuery.noConflict(true); YAHOO.query(”span.hidden”).removeClass(”hidden”); |
|
|
|
|
caroig Gold Membership
 Nuke Master Posts:279

 |
| 2/24/2008 8:21 AM |
|
Posted By llong on 2/23/2008 4:59 PM
* You can now include multiple versions of jQuery, simultaneously, on the same page.
dojo.jquery = jQuery.noConflict(true);
dojo.jquery(”#elem div”).slideDown(”slow”);
// or with Yahoo UI
YAHOO.query = jQuery.noConflict(true);
YAHOO.query(”span.hidden”).removeClass(”hidden”);
How would that work in practise for different versions? If I have two versions of the jQuery object loaded, then which one of them would my jQuery.noConflict apply to? I guess you could load the library, issue the noconflict command and then load the new library. Would that work?
The use of the jQUery.noConflict(extreme) comes with a warning that plugins probably will cease to work. |
|
|
|
|