HomeHelpTrac

Changeset 15725 for trunk/inc


Ignore:
Timestamp:
12/05/11 23:07:45 (6 months ago)
Author:
Alexander Trofimov
Message:

Forms - switcher events were attached several times in some situations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/js/jquery.webForms.js

    r15718 r15725  
    1212        $(this).addNonWebForms(); 
    1313         
    14         $('.bx-switcher-cont').live('click', function() { 
    15             var $this = $(this); 
    16             if ($this.hasClass('on')) {                 
    17                 $this.find('input').removeAttr('checked').trigger('change'); 
    18                 $this.removeClass('on').addClass('off'); 
    19             } else { 
    20                 $this.find('input').attr('checked', 'checked').trigger('change'); 
    21                 $this.removeClass('off').addClass('on'); 
    22             } 
    23             return false; 
     14        // switchers 
     15        $('.bx-switcher-cont', this).each(function() { 
     16            var eSwitcher = $(this); 
     17 
     18            if (eSwitcher.hasClass('bx-form-switcher-processed')) 
     19                return; 
     20            eSwitcher.addClass('bx-form-switcher-processed'); 
     21 
     22            eSwitcher.on('click', function() { 
     23                var $this = $(this); 
     24                if ($this.hasClass('on')) { 
     25                    $this.find('input').removeAttr('checked').trigger('change'); 
     26                    $this.removeClass('on').addClass('off'); 
     27                } else { 
     28                    $this.find('input').attr('checked', 'checked').trigger('change'); 
     29                    $this.removeClass('off').addClass('on'); 
     30                } 
     31                return false; 
     32            }); 
    2433        }); 
    2534 
Note: See TracChangeset for help on using the changeset viewer.