Skip to content

[UI 1.12] jQuery UI: Article on the classes option #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

tjvantoll
Copy link
Member

WIP. I need to make another pass at this after we decide if we're moving forward with _addClass() and _removeClass().


*Note: To get a full list of the class names you can use with `classes`, you can log the default values stored at `$.namespace.wigetName.prototype.options.classes`. For instance the dialog widget's default values are available at `$.ui.dialog.prototype.options.classes`. Additionally, the API documentation for all jQuery UI widgets list the class names they use; here are dialog's: <http://api.jqueryui.com/dialog/#theming>.*

The `classes` option works any other widget factory option, which means all the mechanisms around options still apply. For instance the following code uses the [`option()` method](http://api.jqueryui.com/jquery.widget/#method-option) to remove all class names currently associated with `ui-dialog`:
Copy link
Member

Choose a reason for hiding this comment

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

First sentence, "...works on any other..." need the word 'on' in that sentence.

Copy link
Member

Choose a reason for hiding this comment

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

Not "on", but "like".

@RedWolves
Copy link
Member

This is an awesome start!

});
```

For more examples of this approach, checkout [Alexander Schmitz's repo](https://github.com/arschmitz/jqueryui-bootstrap-adapter) that adapts jQuery UI to work with Boostrap using the `classes` option.
Copy link
Member

Choose a reason for hiding this comment

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

checkout -> check out, unless you actually want them to clone and checkout the code.

@arthurvr
Copy link
Member

arthurvr commented Jan 5, 2015

@tjvantoll Wanne update the PR a little?

@tjvantoll
Copy link
Member Author

@arthurvr I'm waiting for the _addClass(), _removeClass(), and _toggleClass() APIs to finalize before addressing the comments and finishing this article.

@jzaefferer
Copy link
Member

I think the API is now final, could update this.

@tjvantoll
Copy link
Member Author

I addressed all comments and finished the section on custom widgets. This is ready for a review (although note that this shouldn't go live until jQuery UI 1.12 does).


## Syntax overview

The `classes` option is used to map structural class names to custom class names that you define. To see what this means let's look at an example. The code below uses the `classes` option to create a red dialog:
Copy link
Member

Choose a reason for hiding this comment

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

This is not entirely true it maps structural class names to theme class's ( both custom and built in ). You are also doing more then just making the dialog red here you are also removing the rounded corners.

@arschmitz
Copy link
Member

Just as a general comment on the last half of this article on custom widgets. I think that if we are going to get into the use of the new methods in your own widgets we should get into more detail and fully explain their use ( and probably mention some common pitfalls people will run into ). Otherwise i think we should stick to explaining how to use the option and leave custom widgets for another more in depth article or just to the api site.

@gnarf gnarf changed the title jQuery UI: Article on the classes option—new to jQuery UI 1.12 [UI 1.12] jQuery UI: Article on the classes option Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

7 participants