Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Compressing with Asset Packager (using Google's Closure Compiler) does not work #19

Open
jensb opened this Issue · 2 comments

2 participants

@jensb

We are using Asset Packager to compress our CSS and Javascript files. This is a great plus since it allows us to transmit only one compressed CSS and JS file, instead of (altogether) 27 files with each request.

However, when I include CDS's .js files in asset_packager's config/asset_packages.yml, I get the following error upon clicking on a calendar icon:

"'that' is not a function", in initCalendarDiv

It seems that something that asset_packager does, breaks CDS's javascript. What could that be?

@jensb

PS. Using Rails 3.0.4 (and the Rails 3 fork of CDS).

@triemstr

I also had this problem last year and gave up on closure compiler. A better javascript coder than I may be able to figure it out. I would first try to upgrade to the most recent closure compiler to see if it is still a problem. Then if you have a chance, see if you can re-arrange this code in the main calendar_date_select.js file (I suspect it is a problem with the eval line):

https://github.com/timcharper/calendar_date_select/blob/master/public/javascripts/calendar_date_select/calendar_date_select.js

Look around line 145 inside initCalendarDiv:

var that = this;
    // create the divs
    $w("top header body buttons footer bottom").each(function(name) {
      eval("var " + name + "_div = that." + name + "_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ");
    });

Instead of solving this, I just moved to yui from closure. The uglifier gem may also work. I've never tried it but I think it comes with Rails 3.1 so it would be worth trying. I use the jammit gem and yui 0.9.1 to do mine. Yui has newer versions that you should try but I have other unrelated problems with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.