4

Here is the HTML snippet:

<input type="text" name="UPCtext" id="UPCtextBar" value="" placeholder="Type UPC number" class="UPCvalue"/>

There are no events bind()'s or live()'s associated with this input field.

If I remove jQTouch it works as it should, so, have anyone been through this problem?

pgold
  • 41
  • 5
  • I've also run into this problem. Pasting works fine on my iPhone but I cannot paste into a field when viewing the same page in my Mac's version of Safari. I'm also curious to know whether this is intentional and how it might be fixed or worked around. – Mark Reid Feb 23 '10 at 22:21
  • Adding to this WebKit bug theory: I can paste on Firefox, but I can't on Safari and on Chrome. – pgold Feb 24 '10 at 12:57

2 Answers2

1

A quick search for "jqtouch paste" revealed a jqTouch issue that suggests it may be a WebKit inheritance bug. No solution seems to be offered at this stage.

Mark Reid
  • 921
  • 1
  • 6
  • 14
  • Thanks Reid! I've found that issue after posting this question here, but I forgot to edit the original question. – pgold Feb 24 '10 at 12:48
0

I found a workaround:

function fixCopyPaste(el) {
    el.bind('paste', function(e) {
        var element = $(this).context;

        var text = $(this).val();
        var start = element.selectionStart;
        var pastedText = e.originalEvent.clipboardData.getData('text/plain');
        $(this).val(text.substring(0, element.selectionStart)
            +pastedText
            +text.substring(element.selectionEnd, text.length));
        element.selectionStart = start+pastedText.length;
        element.selectionEnd = element.selectionStart;
    });
}

Call this function on the input element that you want to enable paste feature. E.g.:

fixCopyPaste($('#notes'));

It can probably be extented to handle more than one element.

Muxa
  • 5,563
  • 6
  • 46
  • 56