Skip to content

TypeError: hasSticky is undefined #1534

@adamz01h

Description

@adamz01h

updateHeaderCheckbox function should have a is set check before calling in case someone is not using the sticky headers widget. I had to update the code as follows to get a checkbox working as expected.

/*! Parser: input & select - updated 2018-01-30 (v2.29.5) *//*
 * for jQuery 1.7+ & tablesorter 2.7.11+
 * Demo: http://mottie.github.com/tablesorter/docs/example-widget-grouping.html
 */
updateHeaderCheckbox = function( $table, checkboxClass ) {
			var $rows = $table.children( 'tbody' ).children( ':visible' ), // (include child rows?)
				len = $rows.length,
                                hasSticky = $table[0].config.widgetOptions.$sticky;
			

			// set indeterminate state on header checkbox
			$table.children( 'thead' ).find( 'input[type="checkbox"]' ).each( function() {
				var column = $( this ).closest( 'td, th' ).attr( 'data-column' ),
					
					vis = $rows.filter( '.' + checkboxClass + '-' + column ).length,
					allChecked = vis === len && len > 0;
				
					if (hasSticky){
					var $sticky = hasSticky.find( '[data-column="' + column + '"]' );

					}

				if ( vis === 0 || allChecked ) {
					updateCheckbox($(this), allChecked);
					if ($sticky) {
						updateCheckbox($sticky, allChecked);
					}
				} else {
					updateCheckbox($(this), 'indeterminate');
					if ($sticky) {
						updateCheckbox($sticky, 'indeterminate');
					}
				}
			});

		};

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions