jquery tagit不能与IE9一起使用

时间:2013-09-27 07:12:44

标签: javascript jquery internet-explorer internet-explorer-9 tag-it

我遇到了jquery tag-it插件的问题:http://aehlke.github.io/tag-it/

我想使用AJAX获取我的数据,并且只传递id,同时保留标记字段中的标签以显示。

这适用于所有主流浏览器(chrome,FF,safari),除了IE9(没有尝试过更高版本,因为我需要支持IE9)。

这是我的代码:

$("#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;

            }
        }
});

在所有其他浏览器中,值在tag-array中作为键传递,但在IE9中,值仅为0.

我的代码中是否存在明显错误,还是更深层次?

提前致谢。

1 个答案:

答案 0 :(得分:0)

我发现了这个问题。

显然我使用javascript命令“console.log()”因某些原因导致IE崩溃。

谢谢IE。