miletbaker / add_nested_fields

Rails ActionView / RJS Helper to work with dynamically adding removing partials for working with accepts_nested_attributes_for
http://www.gotripod.com
MIT License
21 stars 3 forks source link

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

Closed pbadams closed 14 years ago

pbadams commented 14 years ago

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()) });

miletbaker commented 14 years ago

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 %>