Я искал ответ и не могу найти тот, который работает.coffeescript: функция jquery click только срабатывает один раз
В основном у меня есть функция, которая отправляется на стену Facebook или в твиттер, но функция щелчка срабатывает только один раз.
Вот код:
$('.social a').on 'click', (e) ->
e.preventDefault()
book = book.collectMeta $(@).parents('.book')
if $(@).hasClass 'fb-share'
postFacebook book
if $(@).hasClass 'twitter-share'
postTwitter book
Моя функция collectMeta, что увольняют это:
book =
collectMeta: (dom) ->
# Helper function that collects data of a book and prepares it
# for sharing on sociall media
# The argument for this function accepts the parent DOM Object
# that searches for the appropriate Meta Data
$title = dom.find '.book-title'
title = helper.cleanWhite $title.text()
$author = dom.find '.book-author'
author = helper.cleanWhite $author.text()
$description = dom.find '.book-description'
description = helper.cleanWhite $description.text()
description = helper.trimText(description, 140)
$link = dom.find '.book-link'
link = glob.baseUrl() + $link.attr 'href'
$image = dom.find '.book-image'
image = glob.baseUrl() + $image.attr 'src'
return book =
title: title
caption: author
description: description
link: link
image: image
И ошибка я получаю после первого щелчка, который работает, является: book.collectMeta не является функцией
Любая помощь очень ценится!