JavaScript/CoffeeScript problem in Rails search form

From: Jason Hsu, R.
Sent on: Monday, August 12, 2013 11:51 PM
I have two Rails apps up and running, Bargain Stock Funds and Doppler Value Investing.  Please note that I haven't done any Javascript programming beyond the "Hello World" stage.

Both apps have search engines that uses the Ransack gem (for the search form) and the Kaminari gem (provides paginated results).  The search pages are http://www.bargai...­ and http://www.dopple...­ , respectively.  The URLs for the source code are https://github.com...­ and https://github.com...­ , respectively.

In the production environment (the one that sees the light of day), the "add field" and "remove" buttons on the Doppler Value Investing search page work, but the "add field" and "remove" buttons on the Bargain Stock Funds page do not work.  What's even stranger is the fact that the "add field" and "remove" buttons do work in the development environment.  Yes, the Bargain Stock Funds search page works in the development environment but not in the production environment.

I posted about this on the ruby.mn Google group, and Joshua Wehner suggested that I have a problem with JavaScript and/or CoffeeScript.  Thus, I've decided to post here as well, as this is the forum where the top JavaScript people congregate.

The JavaScript/CoffeeScr­ipt file on the Bargain Stock Funds site is app/assets/javascrip­ts/funds.js.coffee script.  The analogous file on the Doppler Value Investing site is app/assets/javascrip­ts/stocks.js.coffee .  Both have the following code:

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: 
http://jashkenas....­
jQuery ->
$('form').on 'click', '.remove_fields', (event) ->
$(this).closest('.fi­eld').remove()
event.preventDefault­()

$('form').on 'click', '.add_fields', (event) ->
time = new Date().getTime()
regexp = new RegExp($(this).data(­'id'), 'g')
$(this).before($(thi­s).data('fields').re­place(regexp, time))
event.preventDefault­()

Exactly how can I get an error message to appear?  Until I get an error message, I have no way of properly troubleshooting this.  I have downloaded and installed FireBug, and I'm in the process of trying to make sense of it.

-- 
Jason Hsu <[address removed]>

Our Sponsors

  • Twilio

    Super simple API for SMS, MMS, Voice/VoIP in native mobile or web apps

  • CoCo Co-Working

    Our gracious hosts!

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy