johnpolacek / stacktable.js

jQuery plugin for stacking tables on small screens
http://johnpolacek.github.io/stacktable.js/
Other
1.03k stars 167 forks source link

Does not work on dynamiclly created fields. #36

Closed efinst0rm closed 7 years ago

efinst0rm commented 8 years ago

Hello,

I have been using stacktable in my project and it's awesome but today I came across an issue with dynamically created fields in jquery. When you scale the screen down to a smaller size the extra fields created do not show anymore, but when you resize the website to full they appear just fine. Below I've attached the js I'm using to do the dynamic fields. http://pastebin.com/duBWd66F

bruno-vaz commented 8 years ago

You could wrap the $('table').stacktable() code inside a function, like function startStacktable(){ $('table').stacktable() } And then call it again inside the "$(addButton).click()" function, so it generates the mobile version of the table again. Your code would look like this: http://pastebin.com/Xh8WTdrR

jamiecalabro commented 7 years ago

The only issue remaining in your example, when called twice, it duplicates the table. So just remove the first instance, which will make it function properly no matter how many times it's called.

` startStacktable();

if ($('#myTable').find('.stacktable').size() >= 2) { $('#myTable').find('.stacktable:first').remove(); } `