Solved

call a 'nested' function from outside

Posted on 2008-10-31
3
797 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 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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 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)

717 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