I have a small function:
function showVotingModal(e) {
var $collector = $("#vote-collector");
setTimeout(function () {
$collector.addClass("open");
}, 5000);
$collector.find(".description").text($(this).data("desc"));
$collector.attr("data-id", "15");
}
The idea is to show the #vote-collector panel after a delay of 5 seconds and populate some further data withing the panel.
The above code works, however the code below doesn't.
function showVotingModal(e) {
setTimeout(function () {
var $collector = $("#vote-collector");
$collector.addClass("open");
$collector.find(".description").text($(this).data("desc"));
$collector.attr("data-id", "15");
}, 5000);
}
In this case the 'description' tag isn't populated.
Can anyone throw some light on whether I'm doing something wrong, or does the timeout function simply does not work this way?
Thanks