make a comments module. Move module initializing to application.js

This commit is contained in:
kikito
2015-07-30 13:19:34 +02:00
parent f1ebca66c1
commit 1237f9d8ad
2 changed files with 16 additions and 7 deletions

View File

@@ -18,4 +18,13 @@
//= require app
//= require_tree .
$(function(){ $(document).foundation(); });
var initialize_modules = function() {
App.Comments.initialize();
};
$(function(){
$(document).foundation();
$(document).ready(initialize_modules)
$(document).on('page:load', initialize_modules)
});

View File

@@ -1,13 +1,13 @@
jQuery ->
toggle_comment = (id) ->
App.Comments =
toggle_form: (id) ->
$("#js-comment-form-#{id}").toggle()
ready = ->
initialize: ->
$('body').on 'click', '.js-add-comment-link', ->
id = $(this).data().id
toggle_comment(id)
App.Comments.toggle_form(id)
false
$(document).ready(ready)
$(document).on('page:load', ready)