alexgorbatchev / jquery-textext

A super awesome, customizable text input supporting tags, autocomplete, ajax and other goodness in a crazy cool a-la cart way.
http://textextjs.com
MIT License
1.27k stars 201 forks source link

touch devices #143

Open puzsol opened 10 years ago

puzsol commented 10 years ago

There are a few problems with the textext on a touch device.

1 - The autosuggest will only pick the first item (the highlighted one), unless you drag the highlight down to it... this is simply because the touch device doesn't have a hover event to move the highlight, and even though the click event picked up that it was on another item, the highlighted item was still used. So I modified the onClick code to: p.onClick = function(e) { var self = this, target = $(e.target) ;

    if (target.is(CSS_DOT_LABEL)) {
        var div = target.closest('div.' + CSS_SUGGESTION);
        if (div && div.length == 1)
        {
            target = div;
            if (!div.is(CSS_DOT_SELECTED)) {
                self.clearSelected();
                div.addClass(CSS_SELECTED);
            }
        }
    }

    if(target.is(CSS_DOT_SUGGESTION))
        self.trigger('enterKeyPress');

    if (self.core().hasPlugin('tags'))
        self.val('');
};

2 - The tags are not in front until you move the mouse, so if you start with tags already in the box, you can't remove them until you drag over a tag. You can overcome this by adding the "text-tags-on-top" class to the tags div upon startup. Then things seem to work as they should.

So far these are the only issues I have seen/fixed... I hope this helps someone. Thanks Alex.

akc2267 commented 7 years ago

THANK YOU