Skip to content

Instantly share code, notes, and snippets.

@guipdutra
Created July 18, 2013 12:58
Show Gist options
  • Save guipdutra/6029088 to your computer and use it in GitHub Desktop.
Save guipdutra/6029088 to your computer and use it in GitHub Desktop.
halp
$("#pledge_main_pledge_id").on("change", function (event, main_pledge) {
if (main_pledge) {
var url = "<%= auto_fill_custom_fields_pledges_path %>",
params = {main_pledge_id: $(this).val(), edit_path: true};
$(this).parents("form").blockContent();
$.post(url, params, function(data) {
if(data.success) {
var form = $("form");
// Retiro o formulário atual da tela
form.children().remove();
// Colo o novo formulário com os campos preenchidos
form.append($(data.partial).children());
// Chama JS global de dependência de campos customizados
callCustomDataDependencies();
init();
}
});
} else {
$("[id^=pledge_]").val('');
// Chama JS global de dependência de campos customizados
callCustomDataDependencies();
elCapability.data('modal-url', '<%= modal_capabilities_path %>');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment