Changeset 298


Ignore:
Timestamp:
Mar 22, 2010, 2:30:51 PM (14 years ago)
Author:
duh
Message:
  • table editor did not properly de-attach event handlers properly when unselecting rows
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web-app/js/table-editor.js

    r262 r298  
    5252        $(table).selectable({
    5353            filter: this.rowIdentifier,
    54             stop: function() {
    55                 // remember selected rows
    56                 that.selected = $('.ui-selected', table);
    57 
    58                 // bind on change to columns in rows
    59                 that.selected.each(function() {
    60                     that.attachColumnHandlers(this,table);
    61                 })
     54            selected: function(event, ui) {
     55                that.attachColumnHandlers(ui.selected);
     56            },
     57            unselected: function(event, ui) {
     58                that.deAttachColumnHandlers(ui.selected);
    6259            }
    6360        });
     
    6562
    6663    /**
     64     * de-attach input handlers for this row
     65     * @param row
     66     */
     67    deAttachColumnHandlers: function(row) {
     68        var that = this;
     69
     70        $(this.columnIdentifier, row).each(function() {
     71            var input = $(':input', $(this));
     72
     73            // does this column contain an input field
     74            if (input) {
     75                // unbind table editor event handlers
     76                $(input).unbind('.tableEditor');
     77            }           
     78        });
     79    },
     80
     81    /**
    6782     * attach handlers to the input elements in a table row
    6883     * @param row
    6984     */
    70     attachColumnHandlers: function(row,table) {
     85    attachColumnHandlers: function(row) {
    7186        var that = this;
    7287        var count = 0;
     
    7590        var regAutoComplete = new RegExp("ui-autocomplete-input");
    7691
    77         $(this.columnIdentifier, $(row)).each(function() {
     92        $(this.columnIdentifier, row).each(function() {
    7893            var input = $(':input', $(this));
     94
    7995            // does this column contain an input field
    8096            if (input) {
     
    91107                        if (regAutoComplete.test(inputElement.attr('class'))) {
    92108                            // this is a jquery-ui autocomplete field
    93                             inputElement.bind('autocompleteclose', function() {
     109                            inputElement.bind('autocompleteclose.tableEditor', function() {
    94110                                // TODO: autocompletion deselects rows... which is what we don't want
    95111                                //       to happen of course...
    96112                                that.updateSingleInputElements(input, columnNumber, 'input');
    97                             })
     113                            });
    98114                        } else {
    99115                            // regular text element
    100                             inputElement.bind('keyup', function() {
     116                            inputElement.bind('keyup.tableEditor', function() {
    101117                                that.updateSingleInputElements(input, columnNumber, 'input');
    102118                            });
     
    106122                        // single select
    107123                        var columnNumber = count;
    108                         inputElement.bind('change', function() {
     124                        inputElement.bind('change.tableEditor', function() {
    109125                            that.updateSingleInputElements(input, columnNumber, 'select');
    110126                        });
     
    113129                        // checkbox
    114130                        var columnNumber = count;
    115                         inputElement.bind('click', function() {
     131                        inputElement.bind('click.tableEditor', function() {
    116132                            that.updateSingleInputElements(input, columnNumber, 'input');
    117133                        });
Note: See TracChangeset for help on using the changeset viewer.