?
Solved

call a 'nested' function from outside

Posted on 2008-10-31
3
Medium Priority
?
798 Views
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...
jeremyBass
$(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(':');
            $(this).flash({
                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;
                $this.addClass('').prepend($.fn.flash.transform(htmlOptions));
                $(this).contents("embed").not(".readME").addClass("sizeME");
                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

0
Comment
Question by:jeremyBass26
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Tomarse111 earned 1000 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.
0
 
LVL 4

Author Comment

by:jeremyBass26
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...
jeremyBass
0
 
LVL 4

Author Closing Comment

by:jeremyBass26
ID: 31512140
Thanks for responding
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

777 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