Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Missing 'width' option check #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ali997
Copy link

@ali997 ali997 commented Apr 7, 2015

When 'callback' option was missing script was ignoring 'width' option.

This wont work:

$.farbtastic("#color", {width: 250});

This will:

$.farbtastic("#color", {callback: function(){}, width: 250});

Proposed fix will work for now but to avoid any future problems i think there should be something like:

typeof callback === 'function'

@@ -490,7 +490,7 @@ $._farbtastic = function (container, options) {
};

// Parse options.
if (!options.callback) {
if (!options.callback && !options.width) {
options = { callback: options };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be handled differently. If there is no callback property than one should be defined rather than redefining options.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my case i have to initialize script with empty callback, set color and then link to callback. There is no way to set starting color if i don't use input field and i have to initialize with options because you can't set width otherwise. Maybe there should be a color option then?

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

Successfully merging this pull request may close these issues.

2 participants