jquery script placement

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
8/22/2010 2:12:17 PM
Gravatar
Total Posts 8

jquery script placement

Given that mojoPortal provides the jquery files by default, where is the best place to put custom script?  For instance I have some script that will hide or shwo a section of a custom aspx page.  Is it best to just place this code just before the closing tag of the mainContent contentPlaceHolder of my custom page?

Thanks.

8/23/2010 7:23:05 AM
Gravatar
Total Posts 18439

Re: jquery script placement

Hi,

The best way it to load your script from code, you should do it in the OnPreRender event, this will make sure it comes in after the main jQuery files. Here is an example:

private void SetupMainScript()
{
 Page.ClientScript.RegisterClientScriptBlock(typeof(Page),
   "jeasyslider", "\n<script src=\""
   + Page.ResolveUrl("~/ClientScript/jqmojo/easySlider1.7.js" + "\" type=\"text/javascript\" ></script>");

}

protected override void OnPreRender(EventArgs e)
{
 base.OnPreRender(e);
 SetupMainScript();

}

You should sign up for the mojoPortal user group meeting tomorrow night, I will be presenting on how to integrate jQuery plugins.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.