FinalsClub / karmaworld

KarmaNotes.org v3.0
GNU Affero General Public License v3.0
7 stars 6 forks source link

Remove scope issue for js variables in course_detail.html by moving dataTable call in course-detail.js #345

Closed JHilker closed 10 years ago

JHilker commented 10 years ago

Comment chain @https://github.com/FinalsClub/karmaworld/commit/bd1f369355a2150bcfbbd79138a483b2a6c40546

btbonval commented 10 years ago

This looks good for now. Reading it over, I got a neat idea on how to generalize this across the three or four other places it exists.

This is simply passing a dictionary into the jQuery function. We can write the base dictionary here with a scoped name like "datatable_base".

Then extend the dict with the appropriate column arguments based on whether it is for "datatable_course" or "datatable_note". Apply the correct dict based on the situation.

One way to apply the dict is in the template, where the right dict is known. Eg Note templates would apply "datatable_note" hard coded.

Maybe there's a way to tell, from with the JS func, some signature that indicates note or course. In that case, apply the right dict based on the signature directly from the JS file.