views:

55

answers:

1

I'm using Visual Studio 2010 Ultimate on Win XP and I'm having a strange problem.

If I try to build a project where the code fails:

var html = $('<div>').append($('#top').clone()).remove().html();

Visual Studio stops with an error which is normal.

Now if I comment out the line or even delete the line from the code Visual Studio still stops at the same exact line. It doesn't matter if I choose to clean the solution or rebuild it, it doesn't even help to restart Visual Studio. And I know the rest of the code is perfectly legit because before adding this line everything worked fine.

So in short: it seems like Visual Studio is holding on to the line I already removed! Anyone else have this same problem or knows how to fix this?

EDIT: Just to add more info.

The function I'm trying to call is inside a plugin that I wrote. I know the problem is not in connecting to the plugin because there are 2 other methods in the plugin that work fine.

The method code is:

$.fn.tristate = function (options)
{
    var defaults =
        {
            idSAll: ""
        };

    var options = $.extend(defaults, options);

    return this.each(function ()
    {

    }); // End of this.each
}; // End of tristate

And the call to the method is:

$("#multiTest").tristate();

Where "#multiTest" is a div. And the error message is:

"Microsoft JScript error: Object doesn't support this property or method"

It originates in the call to the method (used to originate in the faulty line of code) and goes down to

"jQery.ready();" in jquery-1.4.2.js and from there to "fn.call( document, jQuery );"

EDIT 2: Restarting the computer didn't help, renaming the method didn't work either.

A: 

I fixed the problem but I have no idea why it fixed the problem.

To fix the problem I copied one of the methods that worked, changed the name and deleted the contents. For some reason this worked.

Faulty method:

$.fn.tristate = function (options)
{
    var defaults =
        {
            idSAll: ""
        };

    var options = $.extend(defaults, options);

    return this.each(function ()
    {
        var $obj = $(this);

    });
};

Non-faulty method:

$.fn.tristate = function (options)
{
    var defaults =
        {
            idSAll: ""
        };

    var options = $.extend(defaults, options);

    return this.each(function ()
    {
        var $obj = $(this);

    });
};

As you can see there is no difference between them!

I even compared them with a program called DiffMerge and it found no differences! Still Visual Studio fails to build the first one but not the latter.

So if you get into a problem like the one I described in the question, try to copy a working method if you have one, if not maybe delete the file and start from scratch.

Hjalti