Script load order

Script load order

Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0
edited July 2017 in Free community support

Hi There,

I'm doing this in my web page...

src="../../Scripts/dataTables/jquery.dataTables.js"></script>
src="../../Scripts/dataTables/dataTables.checkboxes.min.js"></script>
src="../../Scripts/jquery-2.1.1.js" type="text/javascript"></script>

and this is also loaded...
@Scripts.Render("~/bundles/jquery")

If I get rid of @Scripts.Render("~/bundles/jquery")
then Datatables works. obviously there's a conflict, what conflict is it and how can I get around this?
By the way if I don't include any of the top 3 includes then it doesn't work.

I think you said that jquery.dataTables.js has to be loaded before any bootstrap file,
it seems to be loaded before jquery, but still the conflict.
Any ideas?

Thanks, Andy

Answers

  • allanallan Posts: 63,893Questions: 1Answers: 10,531 Site admin

    Yes - DataTables is a jQuery plug-in, so you have to load jQuery first.

    If you just change the order so jQuery loads first it should work.

    Keep in mind that you also one to only load a single version of jQuery. I'm not clear if you might be loading multiple versions, but I would suggest against that.

    Allan

This discussion has been closed.