views:

107

answers:

1

I'm using jqtransform on my site. When the user is on a for them to be able to use hot keys to move through the selections. I added this function:

$wrapper.find('a').keydown(function (e) {

            var Esc = 27;

            var code = (e.keyCode ? e.keyCode : e.which);

            if(code== Esc || (code>=65 &&code<=90)){
                var letter = String.fromCharCode(code);

                if (code==Esc)
                    keyCodes = "";
                else{

                    if (keyCodes=='')
                        keyCodes += letter;
                    else
                        keyCodes += letter.toLowerCase();



                    var item = $wrapper.find('a[text^=\'' + keyCodes + '\']:first');

                    item.click();
                }
            }
        });

inside of $.fn.jqTransSelect.

This code works fine in all browsers but IE. the only thing i can find is that IE doesn't like the click event. Can anyone please help me with this?

If i debug into the code I can see that item is a select not an anchor like i would expect it to be, and that confuses me even more.

A: 

It seems that IE do not execute $('a[text^=\'' + keyCodes + '\']:first') selector properly

take a closer look at contains selector. There are some variations of contains selector at comments.

I use regexcontains selector

$.expr[':'].regexcontains = function(obj, index, meta, stack){
return (obj.textContent || obj.innerText || jQuery(obj).text() || '').search(new RegExp(meta[3], "ig")) >= 0;

as

var item = $wrapper.find("a:regexcontains('^" + keyCodes + "'):first");
Chizh