When using the RegisterJavascript() via the ModuleAdminBasePage I have stumbled across an issue that I have overlooked. Cuyahoga uses the IDictionary BasePageControl _javascripts (HashTables) to store the KVPs that are to be rendered to the page in question. When using jQuery script registration order is critical.
I am looking at the least painful solution. Any ideas on which way to go?
SortedDictionary?
I have made a few changes and tests. The solution is a very simple one but it requires making some changes to the BasePageControl.cs (and maybe elsewhere where this issue is present). Here are the steps.
-----------------------------
1) Add this below the 'using System.Collections' directive.
using System.Collections.Specialized;
-----------------------------
2) Change:
private IDictionary _javascripts;
to
//private IDictionary _javascripts;
private OrderedDictionary _javascripts;
-----------------------------
3) Change:
public BasePageControl()
{
this._stylesheets = new Hashtable();
this._javascripts = new Hashtable();
}
to
public BasePageControl()
{
this._stylesheets = new Hashtable();
//this._javascripts = new Hashtable();
this._javascripts = new OrderedDictionary();
}
-----------------------------
That fixes it. From now on the scripts are rendered in the order they are registered.
I am going to make a few more tests and see if there are any other places that need this change.
I do think that this should be added to the build. (Otherwise jQuery usage is a matter of chance!) I found this issue whild building my new
TechArticles module that has jQuery UI admin elements. I will post more on this when it is near finished.
Good point. This should be improved. I created a Jira issue for it.
Thanks.
martijnbGood point. This should be improved. I created a Jira issue for it.
Thanks.
I think there is already be one that I added yesterday. maybe I added it incorrectly or in the wrong place.