     div.append(ul)
     form.prepend(div)
 
-$ ->
+$(document).on 'turbolinks:load', ->
   $container = $('#masonry')
   $container.imagesLoaded(
     ->

      )
  )

$ ->
  if Cookies.get("openTag")
    $('a[data-toggle="tab"]').parent().removeClass('active')
    $("a[href='##{Cookies.get('openTag')}']").click()

      Cookies.set("openTag",items[1], { expires: 365 * 20 })
  )

$(document).on 'turbolinks:load', ->
  $(".pagination").on 'ajax:send', (xhr) ->
    $('#container').infinitescroll('update', {currPage: 1})
    location.href = xhr.target.href
