setContents: function ( content ) {
return this.each( function () {
var scrollTop = this.scrollTop;
- this.select();
- if ( !document.execCommand( 'insertText', false, content ) ) {
- $( this ).val( content );
- }
+ $( this ).val( content );
// Setting this.value may scroll the textarea, restore the scroll position
this.scrollTop = scrollTop;
} );
return this.each( function () {
var allText, currSelection, startPos, endPos;
- if ( !document.execCommand( 'insertText', false, value ) ) {
- allText = $( this ).textSelection( 'getContents' );
- currSelection = $( this ).textSelection( 'getCaretPosition', { startAndEnd: true } );
- startPos = currSelection[ 0 ];
- endPos = currSelection[ 1 ];
+ allText = $( this ).textSelection( 'getContents' );
+ currSelection = $( this ).textSelection( 'getCaretPosition', { startAndEnd: true } );
+ startPos = currSelection[ 0 ];
+ endPos = currSelection[ 1 ];
- $( this ).textSelection( 'setContents', allText.slice( 0, startPos ) + value +
- allText.slice( endPos ) );
- $( this ).textSelection( 'setSelection', {
- start: startPos,
- end: startPos + value.length
- } );
- }
+ $( this ).textSelection( 'setContents', allText.slice( 0, startPos ) + value +
+ allText.slice( endPos ) );
+ $( this ).textSelection( 'setSelection', {
+ start: startPos,
+ end: startPos + value.length
+ } );
} );
},