简体   繁体   中英

jquery tagit not wokting with IE9

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.

I found the issue.

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

Thank you IE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM