Re: Multiple child models in a dynamic form
Has anyone converted this tutorial to jQuery?
I don't know the equivalent of:
$(this).previous().value = '1'
You are not logged in. Please login or register.
Rails Forum - Ruby on Rails Help and Discussion Forum » Tutorials » Multiple child models in a dynamic form
Has anyone converted this tutorial to jQuery?
I don't know the equivalent of:
$(this).previous().value = '1'
You should check out the railscasts - http://railscasts.com/episodes/196-nest orm-part-1
The jQuery needed in the application.js (or wherever) for Rails 3.x is
function remove_fields(link) {
$(link).prev("input[type=hidden]").val("1");
$(link).parent(".fields").hide();
}
function add_fields(link, association, content) {
var new_id = new Date().getTime();
var regexp = new RegExp("new_" + association, "g")
$(link).parent().before(content.replace(regexp, new_id));
}Hosting provided by aTech Media