diff --git a/docs/example-widget-editable.html b/docs/example-widget-editable.html index 4dfc53be..ade8310c 100644 --- a/docs/example-widget-editable.html +++ b/docs/example-widget-editable.html @@ -371,6 +371,7 @@ td.no-edit, span.no-edit {
columnIndex
is now included in the function parameters$element
parameter has been included which contains the contenteditable element. To get the table cell, use $element.closest('td');
false
to revert the content back to it's original value. Example:
$(function(){ @@ -379,7 +380,7 @@ td.no-edit, span.no-edit { widgets : ['editable'], widgetOptions : { // global validate function - editable_validate : function(txt, orig, columnIndex){ + editable_validate : function(txt, orig, columnIndex, $element){ // only allow one word var t = /\s/.test(txt) ? txt.split(/\s/)[0] : txt; return t ? t : false; @@ -392,12 +393,12 @@ td.no-edit, span.no-edit { widgetOptions : { // validate function per column editable_validate : { - 0 : function(txt, orig, columnIndex){ + 0 : function(txt, orig, columnIndex, $element){ // allow up to two words var t = txt.split(' '); return t.length > 2 ? t[0] + (t[1] ? ' ' + t[1] : '') : txt; }, - '.price' : function(txt, orig, columnIndex) { + '.price' : function(txt, orig, columnIndex, $element) { // make sure the price column(s) are using a number return isNaN( txt.replace(/[$,\s]/g, '') ) ? false : txt; } diff --git a/js/widgets/widget-editable.js b/js/widgets/widget-editable.js index 96b76d49..b0694ec3 100644 --- a/js/widgets/widget-editable.js +++ b/js/widgets/widget-editable.js @@ -139,9 +139,9 @@ valid = $this.html(); if (typeof(validate) === "function") { - valid = validate( $this.html(), $this.data('original'), column ); + valid = validate( $this.html(), $this.data('original'), column, $this ); } else if (typeof (validate = $.tablesorter.getColumnData( table, validate, column )) === 'function') { - valid = validate( $this.html(), $this.data('original'), column ); + valid = validate( $this.html(), $this.data('original'), column, $this ); } if ( t && valid !== false ) {