Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-25-2012, 05:02 PM   PM User | #1
alisamii
New Coder

 
Join Date: Nov 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
alisamii is an unknown quantity at this point
Type Issue undefined is not a function

Hi. I am having some problems with a jQuery plugin which is throwing a "Type Issue undefined is not a function" error.

I don't think I can send an attachment here, but I would appreciate if someone would message me and let me know how I could send them a zip file with my dev site (zipped, it is 592K) as it is not online.

I am sure it is a simple issue, but I'm not sure how to solve it.

Thanks,

Ali
alisamii is offline   Reply With Quote
Old 10-25-2012, 05:44 PM   PM User | #2
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 945
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
Can you post some sample code of the function that is throwing the error?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-25-2012, 05:47 PM   PM User | #3
alisamii
New Coder

 
Join Date: Nov 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
alisamii is an unknown quantity at this point
The plugin code is relatively simple.

Code:
(function($) {

    $.fn.polarisSlider = function(options) {

        // set default options
        var defaults = {
            speed : 1000,
            pause : 2000,
            transition : 'fade'
        },

        // Take the options that the user selects, and merge them with defaults.
        options = $.extend(defaults, options);

        // Needed to fix a tiny bug. If the pause is less than speed, it'll cause a flickr.
        // This will check for that, and if it is smaller, it increases it to just about the options.speed.
        if(options.pause <= options.speed) options.pause = options.speed + 100;

        // for each item in the wrapped set
        return this.each(function() {

            // cache "this."
            var $this = $(this);

            // Wrap "this" in a div with a class of "slider-wrap."
            $this.wrap('<div class="slider-wrap" />');

            // Set the width to a really high number. Adjusting the "left" css values, so need to set positioning.
            $this.css({
                    'width' : '99999px',
                    'position' : 'relative',
                    'padding' : 0
                });

                // If the user chose the "slide" transition...
                if(options.transition === 'slide') {
                    $this.children().css({
                        'float' : 'left',
                        'list-style' : 'none'
                    });

                    $('.slider-wrap').css({
                        'width' : $this.children().width(),
                        'overflow' : 'hidden'
                    });             
                }

                // If the user chose the "fade" transition, instead pile all of the images on top of each other.
                if(options.transition === 'fade') {
                    $this.children().css({
                        'width' : $this.children().width(),
                        'position' : 'absolute',
                        'left' : 0
                    });

                    // reorder elements to fix z-index issue.

                    for(var i = $this.children().length, y = 0; i > 0; i--, y++) {      
                        $this.children().eq(y).css('zIndex', i + 99999);
                    }   

                    // Call the fade function. 
                    fade();
                }

                // If the user instead chose the "slide" transition, call the slide function.
                if(options.transition === 'slide') slide(); 


                function slide() {
                    setInterval(function() {
                        // Animate to the left the width of the image/div
                        $this.animate({'left' : '-' + $this.parent().width()}, options.speed, function() {
                            // Return the "left" CSS back to 0, and append the first child to the very end of the list.
                            $this
                               .css('left', 0)
                               .children(':first')
                               .appendTo($this); // move it to the end of the line.
                        })
                    }, options.pause);
                } // end slide

                function fade() {
                    setInterval(function() {
                        $this.children(':first').animate({'opacity' : 0}, options.speed, function() {   
                            $this
                               .children(':first')
                               .css('opacity', 1) // Return opacity back to 1 for next time.
                               .css('zIndex', $this.children(':last').css('zIndex') - 1) // Reduces zIndex by 1 so that it's no longer on top.                  
                               .appendTo($this); // move it to the end of the line.
                        })
                    }, options.pause);
                } // end fade           

            }); // end each     

        } // End plugin. Go eat cake.

    })(jQuery);
The html side of things is a ul that is in a div container:

Code:
<div class="slideshow">
    <ul id="slides">
        <li><img src="images/slide1/commercial-insurance-107807003.jpg" alt="Commercial Insurance"></li>
        <li><img src="images/slide1/employee-benefits-86250418.jpg" alt="Employee Benefits"></li>
        <li><img src="images/slide1/fine-arts-5384764.jpg" alt="Fine Arts"></li>
        <li><img src="images/slide1/personal-insurance-101341654.jpg" alt="Personal Insurance"></li>
        <li><img src="images/slide1/risk-management-96075848.jpg" alt="Risk Management Planning"></li>
    </ul>
</div>
And the script gets called using the following code:

Code:
<script type="text/javascript" charset="utf-8">
        $('ul#slides').polarisSlider({
            speed : 2500,
            pause : 3000
        });
</script><!--End polarisSlider-->
I can also send you a zip of the site. It isn't online.
alisamii is offline   Reply With Quote
Old 10-25-2012, 05:57 PM   PM User | #4
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 945
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
I cannot download zip files at work.

Have you tried placing the last of your code samples inside the jQuery document ready state?
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-25-2012, 05:59 PM   PM User | #5
alisamii
New Coder

 
Join Date: Nov 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
alisamii is an unknown quantity at this point
I'm pretty much a newbie when it comes to jQuery and js in general, so your question went over my head as I have no idea what you mean by "jQuery document ready state"
alisamii is offline   Reply With Quote
Old 10-25-2012, 06:04 PM   PM User | #6
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 945
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
After you load the jQuery file, take your last bit of code:
Code:
<script type="text/javascript" charset="utf-8"> 
        $('ul#slides').polarisSlider({
             speed : 2500,
             pause : 3000
         }); 
</script><!--End polarisSlider-->
.. and do this with it:
Code:
<script type="text/javascript" charset="utf-8">

$(document).ready(function(){
 $('ul#slides').polarisSlider({
             speed : 2500,
             pause : 3000
         });
});
 </script><!--End polarisSlider-->
This will prevent the polarisSlider from being called until after the whole document is loaded.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-25-2012, 06:11 PM   PM User | #7
alisamii
New Coder

 
Join Date: Nov 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
alisamii is an unknown quantity at this point
Still getting the same error
alisamii is offline   Reply With Quote
Old 10-25-2012, 06:24 PM   PM User | #8
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 945
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
Hmmm.. I'm at a loss. Why would it think that "Type Issue undefined" is or is not a function??
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-25-2012, 06:32 PM   PM User | #9
alisamii
New Coder

 
Join Date: Nov 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
alisamii is an unknown quantity at this point
I wish there was someway I could get the site zip to you. If I upload the zip file it to a site and provide you the link, would you be able to download it?
alisamii is offline   Reply With Quote
Old 10-25-2012, 07:07 PM   PM User | #10
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 945
Thanks: 7
Thanked 97 Times in 97 Posts
WolfShade is an unknown quantity at this point
Security settings, here, prevent it.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 10-25-2012, 09:06 PM   PM User | #11
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,451
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Have you tried stepping through it line by line using the debugger built into your browser to find out which line of the code is giving the error?
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 10-26-2012, 07:44 AM   PM User | #12
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,863
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
Quote:
"Type Issue undefined is not a function" error
I’d hazard a guess at that you somewhere are supposed to pass a function callback in another function, but don’t.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:22 PM.


Advertisement
Log in to turn off these ads.