1. #1
    Sencha User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    sarasa is on a distinguished road

      0  

    Default Unanswered: How to search for elements with class starts with particular character and replace th

    Unanswered: How to search for elements with class starts with particular character and replace th


    For example,


    HTML Code:
    <div class="level1"></div>
    <div class="level1 level3"></div>
    I need to search for elements with class name starting with 'level' and programatically replace them as "level2". How can this be achieved in extjs?

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    514
    Answers
    31
    Vote Rating
    82
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    Quote Originally Posted by sarasa View Post
    For example,


    HTML Code:
    <div class="level1"></div>
    <div class="level1 level3"></div>
    I need to search for elements with class name starting with 'level' and programatically replace them as "level2". How can this be achieved in extjs?
    You have two separate issues, really. The first is to find all the elements that match your initial criteria...e.g., has a class name that begins with "level".

    This is rather trivial with Ext JS:

    Code:
    Ext.select('[class^=level]')
    This will only give you back the matching elements, however, not the classes. So in order to handle the instances where one matching element has multiple matching class names that need to be replaced, you'll need to check each class on the element and replace as needed.

    A quick (and definitely not refined or thoroughly tested solution might look like this:

    Code:
    Ext.select('[class^=level]').each(function(el, c, index) {        
            var classlist = el.dom.className.split(' ');
            for (var i = 0; i < classlist.length; i++) {
                var theclass = classlist[i];
                if (theclass.search('^level') != -1) {
                    el.removeCls(theclass);
                    el.addCls('level2');
                }
            }
        });
    Here's a fiddle that you can play with:


  3. #3
    Sencha User
    Join Date
    Sep 2008
    Posts
    21
    Vote Rating
    0
    sarasa is on a distinguished road

      0  

    Default


    Thanks.. Got the idea

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar