Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8420101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:47:59+00:00 2026-06-10T02:47:59+00:00

Even though the unselectable method is supposed to disable text selection, it does not

  • 0

Even though the “unselectable” method is supposed to disable text selection, it does not function properly in IE, at least IE8. The text cursor is still present, and allows for input.

I should assume that it also does not work in IE9, as the Microsoft equivalent CSS attribute “-ms-user-select” has only recently been introduced in IE10, which has not been “officially” released, and is also not currently supported by Windows 7.

I should also question why the webkit version (“-webkit-user-select”) is not included, either. I understand that webkit is a fork of khtml, and it seems to work as intended in Chrome, but I still question the omission.

/**
* Disables text selection for this element (normalized across browsers)
* @return {Ext.Element} this
*/
unselectable : function(){
    var me = this;
    me.dom.unselectable = "on";

    me.swallowEvent("selectstart", true);
    me.applyStyles("-moz-user-select:-moz-none;-khtml-user-select:none;");
    me.addCls(Ext.baseCSSPrefix + 'unselectable');

    return me;
}

Is there a simple way to modify this code in order to provide proper functionality in versions of IE older than IE10?

EDIT: I am having a bit of trouble getting this to work. I have inserted the following in the onReady call, but before the app.

(function() {
    var Ext = window.Ext4 || window.Ext;

    Ext.override(Ext.dom.Element, {
        unselectable: function() {
            var me = this;
            me.dom.unselectable = "on";

            me.swallowEvent("selectstart", true);

            me.applyStyles([
                '-moz-user-select: none;', 
                '-khtml-user-select: none;', 
                '-webkit-touch-callout: none;', 
                '-webkit-user-select: none;', 
                '-ms-user-select: none;', 
                'user-select: none'
            ].join());

            me.addCls(Ext.baseCSSPrefix + 'unselectable');

            return me;
        },

        selectable: function() {
            var me = this;
            me.dom.unselectable = "off";
            // Prevent it from bubles up and enables it to be selectable
            me.on('selectstart', function(e) {
                e.stopPropagation();
                return true;
            });

            me.applyStyles([
                '-moz-user-select: text;', 
                '-khtml-user-select: text;', 
                '-webkit-touch-callout: text;', 
                '-webkit-user-select: text;', 
                '-ms-user-select: text;', 
                'user-select: text'
            ].join());

            me.removeCls(Ext.baseCSSPrefix + 'unselectable');
            return me;
        },
    });
})();

However, I am getting this error:

Uncaught TypeError: Cannot read property ‘Element’ of undefined

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:48:01+00:00Added an answer on June 10, 2026 at 2:48 am

    The line me.dom.unselectable = "on"; is there to handle unselectable for IE9 and lower. This will add an attribute to the element like <div unselectable="on">blah</div>, and that should cause the div’s text to no longer be editable. Is that not working for you?

    Unfortunately Ext’s unselectable and selectable appear to not quite handle webkit, you can fix that by overriding the methods. How to override the method depends on which version of the SDK you are using.

    For App SDK 2.0p and 2.0p2

    These versions of the SDK are built against ExtJS 4.0.7. In Ext 4.0, you can’t use Ext.override to patch up Ext.Element. So you need to be a bit more manual and alter the prototype:

    Ext.core.Element.prototype.unselectable = function() {
       var me = this;
       me.dom.unselectable = "on";
    
       me.swallowEvent("selectstart", true);
    
       me.applyStyles([
        '-moz-user-select: none;', 
        '-khtml-user-select: none;', 
        '-webkit-touch-callout: none;', 
        '-webkit-user-select: none;', 
        '-ms-user-select: none;', 
        'user-select: none'
        ].join());
    
       me.addCls(Ext.baseCSSPrefix + 'unselectable');
    
       return me;
    };
    
    Ext.core.Element.prototype.selectable = function() {
       var me = this;
       me.dom.unselectable = "off";
       // Prevent it from bubles up and enables it to be selectable
       me.on('selectstart', function(e) {
           e.stopPropagation();
           return true;
       });
    
       me.applyStyles([
        '-moz-user-select: text;', 
        '-khtml-user-select: text;', 
        '-webkit-touch-callout: text;', 
        '-webkit-user-select: text;', 
        '-ms-user-select: text;', 
        'user-select: text'
        ].join());
    
       me.removeCls(Ext.baseCSSPrefix + 'unselectable');
       return me;
    };
    

    You should do this as the very first thing inside Rally.onReady()

    For App SDK 2.0p3 and on

    The App SDK for 2.0p3 and forward is built against ExtJS 4.1. They changed Ext.Element to support Ext.override, so here we can do a slightly cleaner solution (this is basically what I originally posted):

    Ext.override(Ext.dom.Element, {
        unselectable: function() {
            var me = this;
            me.dom.unselectable = "on";
    
            me.swallowEvent("selectstart", true);
    
            me.applyStyles([
                '-moz-user-select: none;', 
                '-khtml-user-select: none;', 
                '-webkit-touch-callout: none;', 
                '-webkit-user-select: none;', 
                '-ms-user-select: none;', 
                'user-select: none'
            ].join());
    
            me.addCls(Ext.baseCSSPrefix + 'unselectable');
    
            return me;
        },
    
        selectable: function() {
            var me = this;
            me.dom.unselectable = "off";
            // Prevent it from bubles up and enables it to be selectable
            me.on('selectstart', function(e) {
                e.stopPropagation();
                return true;
            });
    
            me.applyStyles([
                '-moz-user-select: text;', 
                '-khtml-user-select: text;', 
                '-webkit-touch-callout: text;', 
                '-webkit-user-select: text;', 
                '-ms-user-select: text;', 
                'user-select: text'
            ].join());
    
            me.removeCls(Ext.baseCSSPrefix + 'unselectable');
            return me;
        }
     });
    

    In both cases, just slightly tweaking the function to also add styles for webkit, IE, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Even though Lua does not differentiate between floating point numbers and integers, there are
Even though I know that, at least to my knowledge, this is not the
How does the following code work even though the signature of the function in
You have this code in Javascript (even though language choice does not matter): var
Even though it's not part of HTTP 1.1/RFC2616 webapps that wish to force a
One would expect that even though strings are immutable, value-equality and reference-equality would not
Even though the following works: http://jsfiddle.net/N7D5r/ My attempt at using the same code does
Note- even though im using phonegap, the question is not about some issue in
Even though it's a valid method, JComboBox#setVisible doesn't hide my JComboBox . Am I
Even though i know there are at least 2 or 3 topics with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.