Marionette Behaviors is a collection of useful behaviors for Marionette. It doesn't force you to have all dependencies, but it's your responsibility to have them in your project.
Remember that you need to register the behaviors before using them. Also, it is highly suggested to require the behavior directly instead of the whole lib since it will need all the dependencies that you might not need.
All behaviors can reuse the same syntax as events and triggers to target element defined in the ui
object of the view (@ui.someField
). They are converted on rendering.
This behavior allows the use of any jQuery plugins on defined elements.
behaviors: {
jQuery: {
'@ui.dateField': 'datepicker',
'@ui.timeField': {
timepicker: {
format: 'HH:mm'
}
}
}
}
A plugin can be defined using two different ways: a single string or an object. If you don't need to pass anything to the plugin and have only one plugin to apply to that element, a single string should be your best option. However, if you want to pass options and/or want to apply multiple plugins to an element, use an object. The format is the following: functionName: options
. This will result in this: $(element).functionName(options)
.
Works on v0.8.0
This behavior makes it easier to use Stickit by handling bindings definition and applying Stickit to the view.
TODO: Complete usage documentation
Works with v0.5.3
This behavior allows you to integrate the goodness of BootstrapValidator in your views and having client-side validation on your forms.
bootstrapValidator: {
options: {
// ... insert global settings for alls forms ...
},
targets: [
'@ui.form' // uses only defaults settings,
{
selector: '@ui.form',
options: {
// ... extra local options ...
}
},
'@' // special case to target the whole view if it's a form
]
}
The BootstrapValidator behavior integrate the $(form).bootstrapValidator()
call into your views as a behavior. You can pass options into the global options
object to apply to all the BootstrapValidator-ed forms in your view. The targets
list can handle ui hashes or regular jQuery selectors. You may also pass an object with the attribute selector
to define your target and add specific settings to that form into the options
attributes. An @
will target all the forms in the view and apply BootstrapValidator on them.