Simplify some stuff thanks to live()

This commit is contained in:
Eric Allen 2009-10-17 00:03:12 -04:00
parent 290fa3351c
commit f9d37d1d90
4 changed files with 4 additions and 14 deletions

View file

@ -22,7 +22,6 @@ if @saved
page[empty_container_msg_div_id].hide unless empty_container_msg_div_id.nil?
end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"
page['tickler-empty-nd'].hide if source_view_is :deferred
end
else

View file

@ -54,5 +54,3 @@ if @saved
else
page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@todo.errors.count, "error")} prohibited this action from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @todo.errors.each_full { |msg| content_tag("li", msg) }), "id" => "errorExplanation", "class" => "errorExplanation")
end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"

View file

@ -135,8 +135,6 @@ if @saved
else
logger.error "unexpected source_view '#{params[:_source_view]}'"
end
# make sure the behavior of the new/updated todo is enabled
page << "TodoBehavior.enableToggleNotes()"
else
page.show 'error_status'
page.replace_html 'error_status', "#{error_messages_for('todo')}"

View file

@ -86,14 +86,6 @@ var TracksForm = {
}
}
var TodoBehavior = {
enableToggleNotes: function() {
$(".show_notes").unbind('click').bind('click', function () {
$(this).next().toggle("fast"); return false;
});
}
}
$.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
@ -316,8 +308,11 @@ $(document).ready(function() {
/* for toggle notes link in mininav */
$("#toggle-notes-nav").click(function () { jQuery(".todo_notes").toggle(); });
/* show the notes of a todo */
TodoBehavior.enableToggleNotes();
$(".show_notes").live('click', function () {
$(this).next().toggle("fast"); return false;
});
/* fade flashes and alerts in automatically */
$(".alert").fadeOut(8000);