I have a WebGrid in my Razor View. It performs its task in the same way as paging and sorting. Now I need to do paging and sorting in an ajax call, so I assigned it ajaxUpdateContainerId.
Now, when the method is called grid.GetHtml(), its script is created first, and then the Html table. I have jquery loaded at the end of the page (Script Section in _Layout view).
Thanks to this, Ajax functions are useless because they cannot find jQuery.
I have a workaround for this: I copy the resulting script from the page source and paste it into the view script section, and it works, but it still leaves an error in the console, so I think this is not the right solution.
Another workaround is to link to jquery before calling the method grid.GetHtml(), but this will leave two links to the same javascript library. Bad design again.
That way, we can get WebGrid to display the script section in the script, because it should behave logically.
source
share