Jump to content

running a javascript function inside jquery


darksniperx

Recommended Posts

Hi,

 

I have the following line:

$.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height:getHeight() });

 

From the following code:

var boxHeight = document.getElementById('content-area').clientHeight;
function getHeight(){
    boxHeight += 90;
return  boxHeight = boxHeight + "px";    
}
if(boxHeight > 200){
$(document).ready(function(){
$.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height: getHeight() });
});}

 

jquery fn.colorbox just would not run if I put getHeight() in it. Any ways to go around it or fix it?

Well it looks to me like you're trying to get the object before it's even been created. Try this:

 

 

var boxHeight;function getHeight(){    boxHeight += 90;    return boxHeight = boxHeight + "px";   }$(document).ready(function(){    boxheight = $('content-area').height();    if (boxheight > 200){        $.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height: getHeight() });    }});

 

I cant say if what was the case or not. but it seemed the colorbox was not compatible with jquery 1.4.1 and I have applied 1.3.2 for which it automatically grabs the height, and I dont need to specify it. But thx for the suggestion. I will test the code separately. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.