Jquery calling function after Ajax call

Hi,
I am trying to load available tags for the Jquery tagit plugin via Ajax call to my controller. It loads the Jason array as I can see in Firebug but throws this error:
$("#mytags").tagit is not a function

Any help is appreciated. The tagit plugin is installed and other than not using the Array it works just fine in the page.
This for example works just fine:
 $("#mytags").tagit({

        onTagRemoved: function (event, tag) {
            var mytag = $(tag).text();
            mytag = mytag.slice(0, -1);
            $.post("/Tags/RemoveTag?id=@Model.id" + "&" + "tag=" + mytag);
        }
    });

 
$.ajax({

        url: '/tags/AjaxGetTags',
        dataType: 'json',
        success: function (data) {
           $("#mytags").tagit({
                availableTags: data.tags
            });
        }
    });

Open in new window

nikomanekAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nikomanekConnect With a Mentor Author Commented:
After preventing Telerik from loading Jquery a second time it worked.

@Html.Telerik().ScriptRegistrar().jQuery(false)
0
 
hieloCommented:
>> is not a function
that commonly occurs when the plugin is not "imported".  Are you sure you have the file to the path correct?  To verify this, using Firefox install the Web Developer toolbar. Once install click on Information > View Javascript.  If it is unable to import any of the javascript files, you will notice actual HTML code (as opposed to "pure" javascript code) with <title>404 - Page Not Found</title> or something very similar to it.
0
 
nikomanekAuthor Commented:
Hi Hielo,

I am using the tagit plugin in the page and it works without any problems. Just this one particular function does not. I can call $('#mytags').tagit(do something) without any problems but it stops working the moment I include it in a function as described. I just saw that jquery was loaded twice as Telerik loaded it as well. I disabled it for Telerik and now it accepts .tagit (yeah!) but throws a new error. The moment I start typing anything into the tag bar Jquery throws:
a is undefined
 (function(a,b){function cg(a){return d...a:a+"px")}}),a.jQuery=a.$=d})(window);
0
 
nikomanekAuthor Commented:
If using Visual Studio debugger I get:

Microsoft JScript runtime error: Unable to get value of the property 'length': object is null or undefined

In Jquery.min.js (version 1.5.1)
0
 
nikomanekAuthor Commented:
I found the solution for this kind of behaviour in a Telerik forum.
0
All Courses

From novice to tech pro — start learning today.