Giter Site home page Giter Site logo

Comments (2)

hyperlinked avatar hyperlinked commented on May 24, 2024

BTW, if anyone else is having this same issue and going back to a previous version isn't an option and you don't want to modify the original code, you can get around this by directly setting the contents of the oncomplete property when invoking the slideshow.

var slideshow = $('.slideshow').slides(),
api = slideshow.data('slides');

api.opts.oncomplete = function(current) {
  alert('the index number is: '+current);
}

api.opts.onupdate = function(current) {
  alert('put your function actions here');
}

from jquery-slideshow.

i-like-robots avatar i-like-robots commented on May 24, 2024

@hyperlinked thanks for your detailed information. As soon as I started reading I thought "That's because it's a string" so thank you for saving me time checking that too ;-)

I can't think of a reasonable solution to this because functions should be passed by reference within JavaScript and any way of interpreting the string gleaned from the DOM into JS (eval) is best avoided. The other option I can think of is to test if the given property is available within the global namespace, I.E.:

if (typeof this.opts.oncomplete === "string" && window[this.opts.oncomplete]) {
  window[this.opts.oncomplete].call(...);
}

But I think that's somewhat unexpected behaviour. A test to see whether or not the option is callable is probably a sensible step to avoid errors and adding a precautionary note about usage too. However, I don't think adding functionality to interpret a string and best guess what the author meant is a good feature.

from jquery-slideshow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.