jquery tagit not wokting with IE9-Collection of common programming errors

I have a problem with the jquery tag-it plugin found at: http://aehlke.github.io/tag-it/

I want to fetch my data using AJAX, and only pass along the id while preserving the label in the tagfield to show.

This works perfectly in every major browser (chrome,FF,safari) Except IE9 (havent tried higher versions, since i need to support IE9).

Here is my code:

$("#myTags").tagit({
            placeholderText: window.inviteTxt,
            fieldName: "tag[]",
            //minLength: 2,
            autocomplete: {
                   delay: 0,
                   minLength: 2,
                   source: function( request, response ) {
                         $.ajax({
                             url: "/service/search.php",
                             dataType: "json",
                             data: {
                                 cmd: "getTags",
                                 txt: request.term
                             },
                             success: function( data ) {
                                 response( $.map( data , function( item ) {
                                     return {
                                         label: item.label,
                                         value: item.uid
                                     }
                                 }));
                             }
                         });
                     },
                     select : function(event,ui) {
                         window.itemId = ui.item.value;
                         console.log(window.itemId);
                         $("#myTags").tagit("createTag", ui.item.label);
                         return false;
                     },
                     focus: function(event, ui) {
                            window.itemId = ui.item.value;
                            $(this).val(ui.item.label);
                            return false;
                          },
                },
            allowSpaces:true,
            beforeTagAdded: function(event, ui) {
                // do something special


                //if(!contains(window.data,ui.tagLabel)) return false;
            },
            afterTagAdded: function(event, ui) {
                console.log(window.itemId);
                if (window.itemId) {
                    $(ui.tag).find('input').attr('name', "tag[" + window.itemId+ "]");
                    window.itemId = null;

            }
        }
});

In all other browsers, the value is passed along in the tag-array as key, but in IE9, the value is just 0.

Is there an obvious mistake in my code, or is it something deeper?

Thanks in advance.

  1. I found the issue.

    Apparently i used the javascript command “console.log()” which crashes IE for some reason.

    Thank you IE.