Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:03:37+00:00 2026-06-14T10:03:37+00:00

I setup an AnythingSlider with the resizeContents:false option, so content is at its normal

  • 0

I setup an AnythingSlider with the resizeContents:false option, so content is at its normal size inside the slider. It works well with content from page load (content is an image and a text field wrapped into divs). But when I try to update the content of a slide in Javascript, it is not resized.

JS part :

$('#media-slider').anythingSlider({
    buildStartStop: false,
    infiniteSlides: false,
    hashTags: false,
    resizeContents: false,
    enableKeyboard: false,
    stopAtEnd: true
});
$('#add-button').click(function() {
    var current_index = $('#media-slider').data('AnythingSlider').currentPage;
    $('#media-slider li:nth-child(' + current_index + ')').removeClass('empty-slide-item');
    $('#media-slider li:nth-child(' + current_index + ') .slide-picture img').unbind('load').load(function() {
        $('#media-slider').anythingSlider();
    });
    $('#media-slider li:nth-child(' + current_index + ') .slide-picture img').attr('height', 320).attr('src', 'http://dummyimage.com/350x320');
});​

HTML part :

<link rel="Stylesheet" type="text/css" href="http://css-tricks.com/examples/AnythingSlider/css/anythingslider.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<script type="text/javascript" src="http://css-tricks.com/examples/AnythingSlider/js/jquery.anythingslider.js"></script>

<ul id="media-slider">
  <li class="media-slide empty-slide-item">
    <div class="empty-slide"> 
      <input type="button" id="add-button" value="Set image" />
    </div>
    <div class="slide-content">
      <div class="slide-picture">
        <img width="350" height="" src="" />
      </div>
      <div class="slide-text">
        <input type="text" value="new image" />
      </div>
    </div>
  </li>
  <li>
    <div class="slide-content">
      <div class="slide-picture">
        <img width="350" height="420" src="http://dummyimage.com/350x420" />
      </div>
      <div class="slide-text">
        <input type="text" value="image 1" />
      </div>
    </div>
  </li>
  <li>
    <div class="slide-content">
      <div class="slide-picture">
        <img width="350" height="280" src="http://dummyimage.com/350x280" />
      </div>
      <div class="slide-text">
        <input type="text" value="image 2" />
      </div>
    </div>
  </li>
</ul>​

CSS part :

.media-slide .slide-content{display:block;}
.media-slide .empty-slide{display:none;}
.media-slide.empty-slide-item{height:230px;}
.media-slide.empty-slide-item .slide-content{display:none;}
.media-slide.empty-slide-item .empty-slide{display:block; width:300px; height:200px;}​

I setup a jsfiddle to illustrate that : http://jsfiddle.net/YEmM5/.

Slides 2 and 3 are OK.

In Slide 1, if you click on the button it fakes an image upload and places an image in the slide (it also fakes a server response with the size of the image, so it is set explicitely), it is not resized like the others.

I tried to wait for the image to be loaded to call the AnythingSlider update, but nothing happens.

Should I update the slider another way or is it a bug ?

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:03:38+00:00Added an answer on June 14, 2026 at 10:03 am

    According to the documentation (a lot of which seems to be jsFiddle demos) you can Resize AnythingSlider height with dropdowns inside. The demo shows the use of a separate function to recalculate the height.

    So adding this function to your demo:

    adjustHt = function(tar) {
        // animate the slider height to match the accordion height
        var panel = tar.closest('.panel'),
            newHt = 0,
            // target page index
            num = panel.index(),
            // calculate height of all visibile panel contents
            hts = panel.children().children(':visible').map(function(i, e) {
                return (newHt += $(e).outerHeight(true));
            }).get();
        // change height for plugin to prevent height jumping when changing slides
        $('#media-slider').data('AnythingSlider').panelSize[num][3] = newHt;
        // animate height of slider and panel
        $('.anythingSlider, .panel:eq(' + num + ')').animate({
            height: newHt
        }, 600);
    };
    

    and adapting your click handler by removing the unbind/load (which was unnecessarily reinitializing the AnythingSlider) and calling the height adjustment function instead

    $('#add-button').click(function() {
        var current_index = $('#media-slider').data('AnythingSlider').currentPage;
        $('#media-slider li:nth-child(' + current_index + ')').removeClass('empty-slide-item');
        $('#media-slider li:nth-child(' + current_index + ') .slide-picture img').attr('height', 320).attr('src', 'http://dummyimage.com/350x320');
        adjustHt($('.empty-slide'));
        return false;
    });​
    

    creates the desired effect – see demo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have Anything slider setup on a page like something like so $('.anythingSlider').anythingSlider({
SETUP: Using Google Apps Script's UI (doGet) with tabPanel option. At the bottom of
setup.py from distutils.core import setup import py2exe setup(console=['program.py']) The error Traceback (most recent call
Setup: IIS7 serving ASP classic VB script code which generates a dynamic VSC page/file
Setup: I am using JSPs and jQuery. There is a 'parent' page which holds
Setup: I'm looking for insight into using a ABPersonViewContoller without getting data from the
Problem: I'm trying to integrate a slider (carousel) inside an info window of google
Setup: 1) a string trie database formed from linked nodes and a vector array
Setup: I have an HTML page with a fieldset element. The background color of
Setup I'm writing a script to process and annotate build logs from Visual Studio.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.