Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Solution for AnythingSlider and duplicate IDs

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #29448
    oneworld95
    Member

    If you ever use the JW Player (http://www.longtailvideo.com/support/jw-player) inside the AnythingSlider, and you place a video in the last panel of your UL list, you’ll run into a pesky and non-trivial headache: The AnythingSlider automatically duplicates the last "panel" — so it was duplicating the video tag. This fixes it by looking for the duplicate ID of my video tag (all my video tags start with "vid-") and renaming the ID to something random:

    Code:
    $(window).load(function () {
    $(‘[id]’).each(function(){
    var ids = $(‘[id=’+this.id+’]’);
    if(ids.length>1 && ids[0]==this){

    if (this.id.indexOf(“vid-“) != -1){
    this.id = this.id + “_” + Math.floor(Math.random()*11);
    console.warn(‘Multiple ID #’+this.id);
    }
    }
    });
    });

    All the browsers that will need to use the Flash fallback player will now work correctly. Of course, you’d need to change the "vid-" to the start of whatever ID you’ve given your video tag. This issue may also manifest itself in other situations where duplicate IDs are not desirable :D

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.