drvic10k / bootstrap-sortable

adding sorting ability to bootstrap table
MIT License
513 stars 131 forks source link

SyntaxError: An invalid or illegal string was specified #112

Closed schliden closed 5 years ago

schliden commented 7 years ago

Bootstrap sortable works fine, but when the same table markup is loaded into the parent page via XHR, an error appears in the console indicating: "SyntaxError: An invalid or illegal string was specified" on line 20 of bootstrap-sortable.js

I have tried including:

$('.container').on( "click", "th", function() { $.bootstrapSortable(true); });

in the parent pages main.js code, which does seem to fix the SyntaxError, but then causes the table to only sort once per column.

What is the correct way to enable sortable on XHR pages so that the sort works correctly.

Thanks

Tonsofattraction commented 7 years ago

had a similar problem with $.load(...) load sends a request to backend where a template is being rendered. I figured that bootstrap-sorted initialize must be called after the table was created, so I just added <script type="text/javascript" src="...bootstrap-sortable.js"></script> to the end of my template. and removed it from <head>

schliden commented 6 years ago

Actually fixed it in a cleaner way by adding call to $.bootstrapSortable({ applyLast: true }) in the load callback function.