Issue when using FixedHeader with RequiredJS

Issue when using FixedHeader with RequiredJS

AOzAOz Posts: 3Questions: 0Answers: 0
edited April 2014 in FixedHeader
Hi I've been trying to get the FixedHeader (@version 2.1.1-dev) working with the RequiredJS and keep hitting a roadblocks because fixedHeaders library would always be undefined.

I looked at the code and noticed fixedheaders module is defined using module name.
define( 'datatables-fixedheader', ['jquery', 'datatables'], factory );

As I am a fairly new to javascript and requirejs is new to me, I looked at requirejs documents and found a paragraph where they seem to discourage defining modules with a name
These are normally generated by the optimization tool. You can explicitly name modules yourself, but it makes the modules less portable -- if you move the file to another directory you will need to change the name. It is normally best to avoid coding in a name for the module and just let the optimization tool burn in the module names.

I am sure there is a way to get this code working as is, but I broke my head trying to figure out how, instead I changed the code in dataTables.fixedHeader.js to make it work for me.
//define( 'datatables-fixedheader', ['jquery', 'datatables'], factory );
define(['jquery', 'datatables'], factory );

Thank you for this fantastic tool!


  • allanallan Posts: 62,435Questions: 1Answers: 10,246 Site admin
    I was going with the same form factor as jQuery. Having it as a named module seemed a lot more tidy, but thanks for flagging this up. I'll look into it.

This discussion has been closed.