Stump the Panel » jQuery for Everyone

Customise Quick Launch Link using jQuery

(4 posts)
  • Started 3 days ago by mparter
  • Latest reply from AutoSponge
  1. mparter
    Member

    I'd link to customise a link in the Quick Launch in a custom site definition to show a modal dialog box instead of a default hyperlink. Doing it programmatically in .NET doesn't look do-able because the object model for navigation nodes expects a Url.

    My next thought was to modify the link using jQuery when the page loads. However I've not done much with jQuery so how do I go about removing the current hyperlink and add an onclick event handler to open up a modal dialog box, e.g. window.showModalDialog("http://url?tempId=123");

    I've already tried as a test to embed the following into the page PlaceholderMain placeholder using SharePoint Designer but the code didn't seem to fire.

    $(document).ready(function() {
    $('#zz2_QuickLaunchMenun1 > a:first').attr("href", "#");
    $('#zz2_QuickLaunchMenun1 > a:first').click(function() {
    window.showModalDialog("http://server/class/Pages/CoreMaterials.aspx?siteId=b1ce2e86-27bd-4134-9760-e0ba96a3bb1f&unit=F1C612", "", "dialogHeight:400px;dialogWidth:400px;scroll:no;status:no");
    });

    Posted 3 days ago #
  2. mparter
    Member

    OK, I don't think this will work because the quick launch will obviously be on every page of the site and I don't want to have to put some script on every page of the site (x however many sites there will be using this definition).

    Any other ideas appreciated?

    Posted 3 days ago #
  3. mparter
    Member

    Actually, we're using a custom masterpage so I suppose I can check in the javascript if the current page url starts with a particular path, e.g.http://server/class and if it does, modify the link.

    Is this do-able?

    Posted 3 days ago #
  4. mpartner,

    Yes you can do this.

    First, try your selector without the >

    $('#zz2_QuickLaunchMenun1 a:first')

    You can also add a CEWP to your default master and link a file to it. In that file, put your custom code.

    There are a lot of ways to check the current URL (or bits of it). Native ways like the window.location object or SP ways like L_Menu_BaseUrl (global variable). Post here if you still need help with the scripting portion.

    Posted 3 days ago #

RSS feed for this topic

Reply

You must log in to post.