EasyUI Forum
November 05, 2025, 06:28:50 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Set icons conditionally by class [Solved]  (Read 6479 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: June 04, 2015, 04:44:23 AM »

How can I extend the textbox to set it's icons based on a specific class id, something like this:

Code:
  $.extend($.fn.textbox.defaults, {
    icons:function (jq){
     if($(this).hasClass('qbe')) return ([{
      iconCls:'icon-search',
      handler: function(e){
        $(e.data.target).textbox('setValue', 'Something added!');
      }
    }])
  }
})
« Last Edit: June 04, 2015, 07:15:12 AM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 04, 2015, 06:39:52 AM »

The 'icons' is an array not a function. To create the 'icons' dynamically based on the class value, please override the $.fn.textbox.parseOptions function.
Code:
(function($){
    var parser = $.fn.textbox.parseOptions;
    $.fn.textbox.parseOptions = function(target){
        var opts = parser.call(this, target);
        if ($(target).hasClass('qbe')){
            opts.icons = [{
                iconCls: 'icon-search',
                handler: function(e){
                    $(e.data.target).textbox('setValue', 'Something added!');
                }
            }]
        }
        return opts;
    }
})(jQuery);
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: June 04, 2015, 07:14:57 AM »

Great Thanks so much :-)
Logged

-- Licensed User --
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!