
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
backbone-view-options
Advanced tools
A mini Backbone.js plugin to declare and get/set options on views.
A mini Backbone.js plugin to declare and get/set options on views.
// Add the view options functionality to all our views.
Backbone.ViewOptions.add( Backbone.View.prototype );
ButtonView = Backbone.View.extend( {
options : [ "label" ],
initialize : function( options ) {
this.setOptions( options ); // set the view's options from initialization options.
// Options that are white-listed in the view's `options`
// property are now attached to the view object.
console.log( this.label );
}
} );
// Outputs "OK" to the console.
myButtonView = new ButtonView( { "label" : "OK" } );
// Another example showing default values and required options.
WidgetView = Backbone.View.extend( {
options : [
{ "label" : "OK" }, // Use this object syntax to give an option a default value.
"type!" // Use a trailing exclamation mark to indicate that an option is required.
],
initialize : function( options ) {
this.setOptions( options );
},
render : function() {
console.log( this.label );
}
} );
// Outputs "OK" to the console (because the "label" option defaults to "OK").
myWidgetView = new WidgetView( { "type" : "button" } ).render();
// Throws an exception (because the required "type" option is missing).
myOtherWidgetView = new WidgetView( { "label" : "Cancel" } ).render();
Backbone.ViewOptions.add( view, [ optionsDeclarationsProperty ] )
Initialize the view plugin on a view class or instance. Backbone.ViewOptions.add( Backbone.View.prototype )
will make the plugin available on all backbone views. optionsDeclarationsProperty
specifies which view property holds the options declarations array and defaults to "options"
. (If using Backbone < 1.1.0, specify another value to as these older version of Backbone conflict with view.options
.)
An "option declarations" array should be supplied as the options
property of the view class (or as the optionsDeclarationsProperty
property). Each element in the array must be a string or an object.
view.setOptions()
's optionsHash
(see below). The name may optionally be followed by an exclamation mark, which indicates a "required" option.You may alternatively supply a function that returns an array, very much like how you may supply a function that returns a hash for the built-in backbone view.events
property.
view.setOptions( optionHash )
Sets the view's options to the values in optionHash
as appropriate. If a "required" option is not supplied (and not already on the view) an exception is raised.
view.getOptions()
Returns a hash mapping all option names to current values.
view.onOptionsChanged( newValues, previousValues )
callbackThis method, if it exists on a view, is called when option(s) that are already present on the view object are changed via view.setOptions()
. newValues
and previousValues
are hashes of the changed options to their new and old values respectively. This method also has an alias, _onOptionsChanged
.
view.getOptionsNames()
to view.getOptions()
view._onOptionsChanged
optionsDeclarationsProperty
argument to support Backbone < 1.1.0FAQs
A mini Backbone.js plugin to declare and get/set options on views.
We found that backbone-view-options demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.