How do I get an elements height after $.get ... ?
Hi there,
I'm doing my first script with jquery and can't figure out how I can get an element's height after I loaded content to it using $.get(). The alert you see in the code below shows 0, even when I loaded HTML content to the respective element before. Any ideas? Thank you very much!
- function showDetailbox(e,clicked,scrollto) {
- var opened;
- if($(clicked).parent().hasClass('current')) opened = true;
- if(e) e.preventDefault();
- if(scrollto) $('html, body').animate({ scrollTop: $(clicked).offset().top - 100}, 300);
- if(!opened) {
- ;
- for(var i = 0;i<$('.tile-content').length;i++) {
- $('.tile-spacer').eq(i).slideUp();
- $('.detail-box').eq(i).slideUp();
- $('article.list').removeClass('current');
- }
-
-
- var topPx = $(clicked).offset().top;
- var checkHeight = -1;
- var currentTop = 0;
- var href = $(clicked).find('a').attr("href");
- var ajaxHref = href.substring(href.indexOf('#')).replace(/#/,'');
- if(!ajaxHref) ajaxHref = href;
- window.location.hash = ajaxHref;
- $.get(ajaxHref, function(data) {
- $(clicked).parent().find('.detail-box-inner').html(data);
- });
- $(clicked).parent().find('.detail-box').slideDown(400,'swing',function() {
- if(scrollto) $('html, body').animate({ scrollTop: $(clicked).offset().top - 100}, 300);
- else $('html, body').animate({ scrollTop: $(clicked).offset().top - 100}, 0);
-
- });
- for(var i = 0;i<$('article.list').length;i++) {
- currentTop = $('article.list').eq(i).offset().top;
- if(checkHeight < 0 && currentTop > topPx) checkHeight = $('article.list').eq(i).offset().top;
- if($('article.list').eq(i).offset().top == checkHeight) $('.tile-spacer').eq(i).slideDown();
- }
-
- // *** Alert to check if it works
- alert($(clicked).parent().find('.detail-box-inner').height());
-
- $(clicked).parent().addClass('current');
-
- }
- else {
- for(var i = 0;i<$('.tile-content').length;i++) $('.tile-spacer').eq(i).slideUp();
- $(clicked).parent().find('.detail-box').slideUp(400,'swing',function() {
- $(clicked).parent().removeClass('current')});
- window.location.hash = '';
- }
- }
Regards
joschi81