Ok so i have some coffeescript in users.js.coffee which runs a twitter bootstrap popover on scrolling over a username (this is currently working) now what i want to be able to do is use a timeout to hide the popover if a user does not mouse over the popover.
Here is my code (currently throwing Uncaught ReferenceError: timeoutObj is not defined on scrollover of the popover) my problem is obviously with the timeoutObj variable although it should be set in the mouseleave method?
$ ->
timeoutObj = undefined
$(".comment-user-name").popover({
trigger: "manual"
placement: 'top'
template: '<div class="popover" onmouseover="clearTimeout(timeoutObj);$(this).mouseleave(function() {$(this).hide(); });"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
})
$(".comment-user-name").mouseenter((event, ui) ->
$(".comment-user-name").popover('show')
)
$(".comment-user-name").mouseleave((event, ui) ->
timeoutObj = setTimeout (-> $(".comment-user-name").popover('hide') ), 3000
)
This is correct code:
You can not use timeoutObj in
'<div class="popover" onmouseover="...