GithubHelp home page GithubHelp logo

Comments (4)

lorenzos avatar lorenzos commented on August 26, 2024

Can't do it because when I have a string like:

new FloatingTips('myLink');

I have to choose to use it as selector or as element id. I cannot magically understood if a string is an element id or an elements selector :)

If you cannot live without new FloatingTips('myLink'), try to add this at the end of my plugin code:

var RolfFloatingTips = new Class({
    Extends: FloatingTips,
    initialize: function(element, options) {
        if (typeof(element) == 'string') {
            this.parent('#' + element, options); // Call parent class
        } else {
            this.parent(element, options); // Call parent class
        }
    }
});

And then use:

new RolfFloatingTips('top');

from floatingtips.

rolfnl avatar rolfnl commented on August 26, 2024

Quick reply, nice..
I understand I can extend it to fit my own needs, I actually have that on the to-do for tomorrow :)

But I would suggest making it the default.
You could do something like:

elements = Array.from(document.id(elements) || $$(elements));

And work with that.. Slick will be able to parse a string selector with the $$(elements), so it would work if you throw in whatever really. (have to test to make sure of course).

or with document.getElements(selector) as the Slick demo does here: http://mootools.net/demos/?demo=Slick.Finder
Again, throw in whatever you want (string or element)..it'll just work and is more flexible. (correct me if I'm mistaken!)

from floatingtips.

lorenzos avatar lorenzos commented on August 26, 2024

I will try. If I'm not wrong, you say to give the string input to document.id, and then if it returns an Element, use it, else use the string as selector as before. Correct?

from floatingtips.

lorenzos avatar lorenzos commented on August 26, 2024

Closed because not applicable without changing constructor behavior.
If needed, extend the class as I suggested or edit sources.

from floatingtips.

Related Issues (19)

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.