Why popup not working after table sort?

Why popup not working after table sort?

I m using semantic ui framework.

I have table that can be sorted with JS (jquery-tablesort https://github.com/kylefox/jquery-tablesort)

For every table TD I have popup showing and it works. …
If tablesort is used popup is not working anymore :frowning:
I know that issue is because of DOM but I have no idea how to fix it
Here is example: https://jsfiddle.net/master1991/hrxkn7wt/15/

I tried to catch DOM change

$(document).ready(function(){

	//$('.incidedFull').popup({ observeChanges: true });

	var bindElements = function() {

		//$('.incidedFull').popup('hide all');

		$('.incidedFull')
			.popup({
			observeChanges: true,
			on: 'hover'
		});
	};

	$('body').on('DOMSubtreeModified', function(){
		bindElements();
		console.log('ok');
	});
			
});

it works but it does not close old popups. …

How to fix this? :man_shrugging:
Thanks in advance!

I’m going to guess it’s because your tablesort is destroying and recreating your table rows, which is triggering your observeChanges mutation observers.

I have two possible solutions in my head.

#1: Set observeChanges to false.
#2: Instead, use a delegated jquery binding:

$('.tableclass').on('hover',".incidedFull",function(e) { $(this).popup({observeChanges: true}); });
1 Like

Hm doesn’t look like that though… they’re just appending the same rows elsewhere:

However this still does trigger the popup to destroy itself, so as @m_hutley suggests just set observeChanges to false… this would probably be more economical that destroying and re-initializing the popups on every table sort.

2 Likes

Thanks for answer! I did try observeChanges set to false before . … It did not worked! And does not work now to (on my code) but it works on fiddle :man_shrugging: now I m confused what is different on my end?

EDIT: I did find why it worked on test fiddle. … Tablesort version on my end was Version 0.0.1 but on fiddle Version 0.0.11. … I updated tablesort version on my end and now it works!

Thanks guys!

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.