Chinh Do

Problem with jqModal/jQuery JavaScript Intellisense and Workaround

31st March 2009

Problem with jqModal/jQuery JavaScript Intellisense and Workaround

Is anyone else experiencing a problem with Visual Studio 2008 Intellisense with jQuery and jqModal?

It seems that jqModal (a jQuery plugin for modal dialogs) is breaking jQuery Intellisense on my Visual Studio 2008 setup. Without a reference to jqModal.js, jQuery Intellisense works fine:

image

As soon as I add the reference to jqModal.js, the Intellisense stops working with this error:

Warning    1    Error updating JScript IntelliSense: …\scripts\jquery-1.3.2-vsdoc.js: ‘jQuery.support.htmlSerialize’ is null or not an object @ 1430:4

Workaround

To work around the problem, generate the script include tag dynamically so that the JavaScript Intellisense engine doesn’t see the jqModal reference at design time.

<head runat="server">
    <title>My Web</title>
    <asp:Literal ID="LitJqModalScript" runat="server"></asp:Literal>
    <script src="../scripts/jquery-1.3.2.js" type="text/javascript"></script>
</head>

 

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    LitJqModalScript.Text = @"<script src=""../scripts/jqModal.js"" type=""text/javascript""></script>";
}
This entry was posted on Tuesday, March 31st, 2009 at 7:15 am and is filed under Dotnet/.NET - C#, Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There are currently 5 responses to “Problem with jqModal/jQuery JavaScript Intellisense and Workaround”

  1. 1 On August 5th, 2009, Charles said:

    I had the same problem but in a MVC project, what I’ve done is that a I created a HtmlHelper extension that renders, something like this:

    public static string IncludeJavaScriptFile(this HtmlHelper helper, string fileName)
    {
    return string.Format(“”, fileName);
    }

    Then I included my scripts in my masterpage with this, and for intellisense support I added the vsdoc file in my master like this:

    And now it works perfectly

  2. 2 On November 17th, 2009, Artem Baybuzskiy said:

    you can simply use something like:
    <script src=”" type=”text/javascript”>

  3. 3 On November 24th, 2009, Tim Fischer said:

    I really needed this debugged and didn’t like the workarounds. So I fixed the code:

    change the following line near the end of the function:
    i = $(”).css({ opacity: 0 }),

    TO:

    i = $(”).addClass(‘jqm’).attr(‘src’, “javascript:false;document.write(\’\');”).css({ opacity: 0 }),

    Intellisense will now work as well as jqModal.

    Tim

  4. 4 On November 24th, 2009, Tim Fischer said:

    Well – the code got stripped, but you get the idea… :(

  5. 5 On November 24th, 2009, Chinh Do said:

    Tim: Thanks for the tip.

Leave a Comment

*