Reputation:
I have this situation.
$(document).ready(function(){
$.each(elements,do());
});
I would like to execute another new method after the $.each()
has finished new method called doOther()
.
Where I can set my new method for example doOther();
? I have new $.each
inside new method just for info.
Update
This is my script
$(function(){
$.each($('.countdown'), function() {
var _element = '.countdown-'+$(this).attr("id");
if ($(_element).length > 0) {
var _expDate = $(_element).attr('data-expiration').split(',');
_expDate.forEach(function(v,i,a){a[i]=parseInt(a[i]);});
var _datetime = new Date(_expDate[0],_expDate[1],_expDate[2],_expDate[3],_expDate[4],_expDate[5]);
init_countdown(_element,_datetime);
}
});
$.each($('.countdown'),function() {
var ips = $(this).text().split(',');
$(this).html('<div class="span12">'+ips[0]+'</div>');
});
});
function init_countdown(_element,_datetime){
$(_element).countdown({
date: _datetime /*"June 7, 2087 15:03:26"*/
});
}
it seems that $.each($('.countdown')
etc.. is overridden by the first $.each
, can't understand why.
Upvotes: 0
Views: 60
Reputation: 5540
This should do it,
$(document).ready( function(){
$.each(elements,do());
doOther();
} );
Upvotes: 1
Reputation: 337560
If I've understood what you mean, your code should look like this:
$(document).ready(function(){
$.each(elements, do);
doOther();
});
If this isn't what you meant, please edit your original question and add more detail.
Upvotes: 3