Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Setting data-dropify attribute with something truthy makes Dropify object not be setted #93

Open
yvesmedhard opened this issue Sep 5, 2018 · 0 comments

Comments

@yvesmedhard
Copy link

Hello

When I set an data attribute 'data-dropify' with something truthy on my element and call element.data() the library do not instantiate the object Dropify correctly as the if results in false.

<input data-dropify="true">My input</input>
var input = $('[data-dropify="true"]');
var data = input.data();
input.dropify({});
$.fn[pluginName] = function(options) {
    this.each(function() {
    // as the data-attribute data-dropify is something truthy and not 
    // the Dropify instance it will not create it but will not work too.
        if (!$.data(this, pluginName)) {
            $.data(this, pluginName, new Dropify(this, options));
        }
    });

    return this;
};

So naming data-dropify data attribute is not a good pratice, but it would be better to the library to not depend on this, making a validation that the result of this call is the Dropify object and not something truthy only.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant