miletbaker / add_nested_fields

Rails ActionView / RJS Helper to work with dynamically adding removing partials for working with accepts_nested_attributes_for

Home Page:http://www.gotripod.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReferenceError: Can't find variable: $ when calling add_nested_fields_for

pbadams opened this issue · comments

I have a nested model set up and working correctly. Installed plugin and followed instructions. When testing the add link on form there alert
"RJS error:

ReferenceError: Can't find variable: $"

is displayed followed by another alert:
$('locs').insert({ bottom: '<div class="location">\n

\n <label for="contact_locations_attributes_NEW_RECORD_name">Name</label> <input id="contact_locations_attributes_NEW_RECORD_name" name="contact[locations_attributes][NEW_RECORD][name]" size="30" type="text" />\n </p>\n

\n <label for="contact_locations_attributes_NEW_RECORD_address">Address</label> <input id="contact_locations_attributes_NEW_RECORD_address" name="contact[locations_attributes][NEW_RECORD][address]" size="30" type="text" />\n </p>\n

\n <label for="contact_locations_attributes_NEW_RECORD_cost_kwh">Cost kwh</label> <input id="contact_locations_attributes_NEW_RECORD_cost_kwh" name="contact[locations_attributes][NEW_RECORD][cost_kwh]" size="30" type="text" />\n </p>\n</div>'.replace(/NEW_RECORD/g, new Date().getTime()) });

This is likely because it can't find the dependent Prototype framework. Make sure you include it in the header by putting in the following tag

<%= javascript_include_tag :defaults %>