Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Error with code

  1. #1
    Regular Coder
    Join Date
    May 2009
    Posts
    141
    Thanks
    64
    Thanked 1 Time in 1 Post

    Error with code

    Hi guys, struggling to sort out why I am getting this error. I have some code which displays some circles around a center circle. At the moment, for the smaller circles, I have
    Code:
    <div id="circle_portfolio">
            <div id="one" class="circle" data-group="portfolio">
                  <img class="img-position" src="thumbs/1.png" alt=""/>
            </div>
            <div id="two" class="circle" data-group="portfolio">
                  <img class="img-position" src="thumbs/2.png" alt=""/>
            </div>
    </div>
    And the js code I have
    Code:
    function move($elem,speed,turns){
                        var id = $elem.attr('id');
    	            var $circles = $("div.circle[data-group='" + id + "']");
    
                        $circles.each(function(index, $circle) {
    					setTimeout(function() {
    						var end = (65 - 360 * (turns-1)) - (index * 15);
    						$circle.stop()
    						.animate({
    							path : new $.path.arc({
    								center	: [409,359],
    								radius	: 257,
    								start	: 180,
    								end		: end,
    								dir		: -1
    							}),
    							opacity: '1'
    						},speed);
    					}, index * 150);
    				});
                    }
                });
    The error I get is
    TypeError: $circle.stop is not a function
    Not to sure why I get this error, any advice appreciated.

    Thanks

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,459
    Thanks
    0
    Thanked 632 Times in 622 Posts
    There is nowhere in that code where you define $circle.stop

    If it is defined elsewhere in your code then post the part where it is defined
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    nick2price (05-28-2013)

  • #3
    Regular Coder
    Join Date
    May 2009
    Posts
    141
    Thanks
    64
    Thanked 1 Time in 1 Post
    Sorry to sound stupid, but what exactly do you mean by define? The each function is passed $circle, and within this is the line $circle.stop()

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,459
    Thanks
    0
    Thanked 632 Times in 622 Posts
    $circle.stop() is trying to call a method called stop belonging to the $circle object. In order to be able to call that method the method must first be defined on the $circle object so that the code to run when stop() is called will exist when that statement is run.

    It is somewhat similar to your visiting a house under construction and wanting to step inside on the floor - the floor has to be inserted into the house before you can walk on it. In this case the meaning of stop for $circle objects needs to be defined before you can call it.

    What exactly is it that you expect the stop() call to do?
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,474
    Thanks
    6
    Thanked 980 Times in 953 Posts
    This looks like jQuery, the stop() function is defined in the core library. The OP has just posted this in the wrong section without any further explanation.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •