Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    24
    Member #
    26848
    Liked
    1 times
    Hello,

    I'm using a jQuery plugin called Quotator to display some testimonials on a site. And what I would like to do is have two different testimonial displays next to each other, one for customer testimonials and one for industry testimonials.

    Now, I've managed to split the plugin into two different sets and each one works when it's the only one on the page. But when I try to call both, only one of them works. I'm just not sure where the conflict is.

    Here's the code:

    Set 1:
    //Script link:
    <script src="Scripts/quotator1.js" type="text/javascript"></script>

    //quotator1.js code:
    // JavaScript Document
    (function($){
    $.fn.quotator = function(options){
    var container = this;
    var defaults =
    {
    speed : 5000,
    json : "quotator_quotes1.js"
    }

    var options = $.extend(defaults, options);

    var quotes_json = options.json;
    var quotes;

    $.getJSON(quotes_json, function(data){
    var quotesobject = eval(data.quotes1);
    var index = 0;

    setInterval(changeQuote, options.speed);

    container.html(quotesobject[index].quote + "<div id='author1'>" + quotesobject[index].author + "</div>");

    function changeQuote(){
    container.fadeOut(function(){
    container.html(quotesobject[index].quote + "<div id='author1'>" + quotesobject[index].author + "</div>").fadeIn();
    });

    if(index == quotesobject.length - 1){
    index = 0;
    } else{
    index++;
    }
    }

    });
    return container;
    }
    })(jQuery);

    //Function:
    <script type="text/javascript">
    $(document).ready(function(){
    $("#quotes1").quotator({
    speed : 15000,
    json : "scripts/quotator_quotes1.js"
    });
    });
    </script>

    And set 2:
    //Script link:
    <script src="Scripts/quotator2.js" type="text/javascript"></script>

    //quotator2.js code:
    // JavaScript Document
    (function($){
    $.fn.quotator = function(options){
    var container = this;
    var defaults =
    {
    speed : 5000,
    json : "quotator_quotes2.js"
    }

    var options = $.extend(defaults, options);

    var quotes_json = options.json;
    var quotes;

    $.getJSON(quotes_json, function(data){
    var quotesobject = eval(data.quotes2);
    var index = 0;

    setInterval(changeQuote, options.speed);

    container.html(quotesobject[index].quote + "<div id='author2'>" + quotesobject[index].author + "</div>");

    function changeQuote(){
    container.fadeOut(function(){
    container.html(quotesobject[index].quote + "<div id='author2'>" + quotesobject[index].author + "</div>").fadeIn();
    });

    if(index == quotesobject.length - 1){
    index = 0;
    } else{
    index++;
    }
    }

    });
    return container;
    }
    })(jQuery);

    //Function:
    <script type="text/javascript">
    $(document).ready(function(){
    $("#quotes2").quotator({
    speed : 15000,
    json : "scripts/quotator_quotes2.js"
    });
    });
    </script>

    If anyone can help, I'd really appreciate it.
    Blake

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:14 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com