Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

call a 'nested' function from outside

Posted on 2008-10-31
3
Medium Priority
?
803 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 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

564 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