tracks/app/views/contexts/edit.js.erb
Reinier Balt 4cdbd9a451 move js genreated for ajax calls into their own object to prevent name clashes
I only modified the js that is most likely to be used in cocurrent calls. This because we
start the development of Tracks 3 that will change all js.
2014-08-13 15:33:32 +02:00

25 lines
No EOL
799 B
Text

<%- object_name = unique_object_name_for("edit_context_#{@context.id}") %>
var <%=object_name%> = {
animate: function() {
<%=object_name%>.replace_context_with_edit_form();
},
replace_context_with_edit_form: function() {
$('div#<%=dom_id(@context)%>').fadeOut(250, function() {
<%=object_name%>.show_edit_form();
<%=object_name%>.set_focus();
});
},
show_edit_form: function() {
$('div#<%=dom_id(@context, 'edit')%>').html(<%=object_name%>.html_for_edit_form());
$('div#<%=dom_id(@context, 'edit')%>').fadeIn(500);
},
set_focus: function() {
$('input.context-name').focus();
},
html_for_edit_form: function() {
return "<%= escape_javascript(render(:partial => 'context_form', :object => @context)) %>";
}
};
<%= object_name %>.animate();