diff --git a/src/bootstrap-wysiwyg.js b/src/bootstrap-wysiwyg.js index 8d7f214..4d4b3cb 100644 --- a/src/bootstrap-wysiwyg.js +++ b/src/bootstrap-wysiwyg.js @@ -58,18 +58,19 @@ this.updateToolbar( editor, toolbarBtnSelector, options ); }.bind( this ) ); + var self = this; $( window ).bind( "touchend", function( e ) { - if(!this.getCurrentRange) + if(!self.getCurrentRange) return; var isInside = ( editor.is( e.target ) || editor.has( e.target ).length > 0 ), - currentRange = this.getCurrentRange(), + currentRange = self.getCurrentRange(), clear = currentRange && ( currentRange.startContainer === currentRange.endContainer && currentRange.startOffset === currentRange.endOffset ); if ( !clear || isInside ) { - this.saveSelection(); - this.updateToolbar( editor, toolbarBtnSelector, options ); + self.saveSelection(); + self.updateToolbar( editor, toolbarBtnSelector, options ); } } ); }