Backbone is an incredibly powerful framework, but it can't do everything. If you want to add a calendar widget, a rich text editor, or a node tree to your site, you'll probably want to use another library, which can provide such a component for you (for example, jQuery UI, TinyMCE, or jsTree). However, just because you want to use a tool other than Backbone, it doesn't mean you have to give up all of the convenience and power of Backbone classes. In fact, there are a number of benefits of creating a Backbone View
class that wraps your third-party component.
First, wrapping the component in a View
allows you to specify a common way of using this component. For instance, let's say you wanted to use the JQuery UI calendar widget (or datepicker
) in your site. In jQuery UI, if you want your calendar to include a month-picking control, you have to supply a changeMonth: true
option in every place in your code that creates a calendar:
// File #1 $('#datepicker1...