prevents for Comments.initialize to be called twice causing unexpected behaviour in forms, when initialize_modules is called on ajax:complete

This commit is contained in:
David Gil
2015-08-14 21:23:06 +02:00
parent f835154233
commit 994774ec65
2 changed files with 15 additions and 7 deletions

View File

@@ -31,7 +31,5 @@ $(function(){
$(document).ready(initialize_modules);
$(document).on('page:load', initialize_modules);
$(document).on('ajax:complete', function(){
App.Users.initialize();
});
$(document).on('ajax:complete', initialize_modules);
});

View File

@@ -17,7 +17,17 @@ App.Comments =
$("#js-comment-form-#{id}").toggle()
initialize: ->
$('body').on 'click', '.js-add-comment-link', ->
id = $(this).data().id
App.Comments.toggle_form(id)
false
# $('body').on 'click', '.js-add-comment-link', ->
# id = $(this).data().id
# App.Comments.toggle_form(id)
# false
#
$('body .js-add-comment-link').each ->
$this = $(this)
unless $this.data('initialized') is 'yes'
$this.on('click', ->
id = $(this).data().id
App.Comments.toggle_form(id)
false
).data 'initialized', 'yes'