call a 'nested' function from outside

Posted on 2008-10-31
Last Modified: 2013-11-11
Hello, I'm sure this is easier then I'm thinking but ... what I need to do is fire the doSomething();  and or the "$(window).bind('resize', ...etc" functions out side of the "$('[class^=Round_gen]').filter(function() {... etc"

... right now they are inside so I could get them working... but they loop every time.... I want to do them all at once... just not sure how to call them for out side....

thanks for the help...
$(document).ready(function() {

    var SORUCE = '/rounded_rectangle_r.swf';

    $('.Round_gen53').attr('rel', '' + SORUCE + ':::transparent:45:0');

    $('[class^=Round_gen]').filter(function() {

        return /Round_gen[0-9]+/.test($(this).attr('class'));

    }).each(function() {

        $(this).each(function() {

            var $this = $(this);

            var params = $(this).attr('rel').split(':');


                flashvars: {

                    rounded: ['' + params[4] + ''],

                    stroke_w: ['' + params[5] + ''].join(' ')




                version: 8


            function(htmlOptions) {

                var self = this;

                $this.css("padding-right", "" + params[11] + "px");

                $this.css("position", "relative");

                htmlOptions.width = self.offsetWidth;

                htmlOptions.src = params[0];

                htmlOptions.wmode = params[3];

                this.innerHTML = '<div class="" style="">' + this.innerHTML + '</div>';

                htmlOptions.height = this.firstChild.offsetHeight;



                function doSomething() {  //// move this out????

                    var NEWheight = self.childNodes[1].offsetHeight;

                    var NEWwidth = self.childNodes[1].offsetWidth;

                    $this.contents(".sizeME").css("height", NEWheight + 'px');

                    $this.contents(".sizeME").css("width", (NEWwidth + 20) + 'px');

                    $this.css("height", NEWheight + 'px');

                    var SAheight = $('.thrColLiqHdr').innerHeight();

                    //alert (SAheight);

                    $('.traction').css("height", SAheight + 'px');


                var resizeTimer = null; //// move this out????

                $(window).bind('resize', //// move this out????

                function() {

                    if (resizeTimer) clearTimeout(resizeTimer);

                    resizeTimer = setTimeout(doSomething, 3);


		doSomething(); //// move this out????




var SAheight = $('.thrColLiqHdr').innerHeight();

	//alert (SAheight);

		$('.SA').prepend('<img class="traction" src="images/blank.gif" style="position:absolute; left:0px; top:0px; width:100%; height:'+ SAheight +';">');


Open in new window

Question by:jeremyBass26
  • 2
LVL 15

Accepted Solution

Tomarse111 earned 500 total points
ID: 22854547
I'm not 100% positive on what you want to achieve but nested functions can only be run locally; that is to say you can't run doSomething() on it's own because it only exists when the outer function is run. This is because even though the function is compiled it's not executed until you call it.

Hopefully that answers your question.

Author Comment

ID: 22855325
Well, yes it and no... I was pretty sure that was how it worked... but never read it... I guess I meant to say it was how could it be reworked to have the doSomething() function be out side so I may run the core of the whole function by it's self but also run the doSomething() function which alters what the core function did... hope that made sense...

I guess I'm just looking for a way refactor this function so it uses as little cpu cycles as possible...
thanks for the help...

Author Closing Comment

ID: 31512140
Thanks for responding

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now