I am integrating DataTables jQuery plugin in an ASP.NET MVC 3 app. Inside jQuery .ready() function I am attaching DataTable to an existing Table.
Now, I need to load ASP.NET MVC dynamically. Where would be the best place to attach DataTable plugin on the dynamically loaded views? “Success” function of the $.get() would be a good place to attach the plugin after I’ve added the HTML to the DOM?
Thanks
I would use the
successmethod as you mention. The key being that:<table>has been created.As long as the above criteria has been met, then go ahead and uses the
.datatable()plugin.I have a couple of MVC projects where I use this technique myself for updating the content of a table which then needs to become a DataTable (i.e. for sorting, searching, etc).