0

It's a long shot which is not that investigated yet, but I'm throwing the question while I'm looking for answers to hopefully get on the right track.

Building a Wordpress site with the theme Dante. This has an image slider function for products, handled in jquery.flexslider-min.js. In my first attempt i used wp_dequeue_script( 'sf-flexslider' ); to stop using this, and then added my own js which works perfect. The problem, however, is that in the bottom of the page there's another slider for displaying other products that uses this file, so i can not simply just dequeue this script.

I've tried to put my js-file both before and after the jquery.flexslider-min.js but this is always the primary. It there a way to, in my js-file, do something like "for obects in [specified div], skip instructions from jquery.flexslider-min.js"?

EDIT: Found this thread and tried the .remove() and the .detach() approach and add it again, but this makes no difference.

I really want to get rid of that flexslider on this particullar object. I can, of course, "hack" the output and give the flexslider item another class or something, but that would bring me so much work i don't have time for.

Community
  • 1
  • 1
gubbfett
  • 2,157
  • 6
  • 32
  • 54

1 Answers1

0

Maybe, You can monkey patch the flexslider behavior. There's a good tutorial here: http://me.dt.in.th/page/JavaScript-override/

Something like:

var slider = flexSlider;

var originalSlide = slider.slide;
slider.slide= function() {
  if ( some condition) {
     // your custom slide function
  } else {
     // use default behavior
     originalSlide.apply(this, arguments);
  }

}

kmandov
  • 3,130
  • 16
  • 15
  • the slider is originally called from the themes functions.js, with var flexslider = { init: function(){ ... [the ul-object].flexslider({..., how can i "undo" this call in another js-file? :) – gubbfett Nov 28 '14 at 11:40