Solved

call a 'nested' function from outside

Posted on 2008-10-31
3
791 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
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
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.
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java script read and write file - save as location 8 42
Html5 Index on a table 7 25
javascript comparing two dates 3 18
jQuery for Each 12 16
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

805 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