Initializes a Falcon application and applies its bindings against an initial view.
- root
- A view or an observable containing a view to be applied to the application element
- element
- The element to initialize the application in. If none is provided, the body element is used.
- callback
- Method called after the bindings have been initialized and applied.
1 var LayoutView = Falcon.View.extend({ "url": "#layout_view_tmpl" });
2
3 // Applies the view and bindings to the 'body' tag
4 Falcon.apply( new LayoutView );
5
6 // Applies the view and bindings the element with id="application"
7 Falcon.apply( new LayoutView, "#application" );
8
9 // Falcon.apply can also handle observables
10 // Applies the observable to the 'body' tag, nothing is currently rendered
11 var viewObs = ko.observable();
12 Falcon.apply( viewObs );
13
14 // Renders a layout view in 'body'
15 viewObs( new LayoutView );
Used to create a new binding. If the allowVirtual flag is set, then the binding may also be used as a virtual binding.
- name
- The binding name.
- allowVirtual
- Should this binding be accessible using Knockout's virtual binding pattern?
- definition
- The binding definition.
- name
- The binding name.
- allowVirtual
- Should this binding be accessible using Knockout's virtual binding pattern?
- update_function
- The function to apply to the 'update' key in the binding definition.
1 Falcon.addBinding("slideVisible", {
2 update: function(element, valueAccessor, allBindingsAccessor) {
3 // First get the latest data that we're bound to
4 var value = valueAccessor(), allBindings = allBindingsAccessor();
5
6 // Next, whether or not the supplied model property is observable, get its current value
7 var valueUnwrapped = ko.unwrap(value);
8
9 // Grab some more data from another binding property
10 // 400ms is default duration unless otherwise specified
11 var duration = allBindings.slideDuration || 400;
12
13 // Now manipulate the DOM element
14 if (valueUnwrapped == true) {
15 $(element).slideDown(duration); // Make the element visible
16 } else {
17 $(element).slideUp(duration); // Make the element invisible
18 }
19 }
20 });
Used to look up a specific binding definition object based on the binding's name.
- name
- The binding name.
1 binding_definition = Falcon.getBinding("foreach");
2 console.log( binding_definition ); // The binding definition object
Method used to test if an object is a Falcon Adapter.
- object
- The Object to test
1 var array = [];
2 var object = new Falcon.Object();
3 var collection = new Falcon.Collection();
4 var model = new Falcon.Model();
5 var view = new Falcon.View();
6 var adapter = new Falcon.Adapter();
7
8 console.log( Falcon.isAdapter(array) );// false
9 console.log( Falcon.isAdapter(object) );// false
10 console.log( Falcon.isAdapter(model) );// false
11 console.log( Falcon.isAdapter(collection) ); // false
12 console.log( Falcon.isAdapter(view) );// false
13 console.log( Falcon.isAdapter(adapter) );// true
Method used to test if an object is a Falcon Collection.
- object
- The Object to test
1 var array = [];
2 var object = new Falcon.Object();
3 var collection = new Falcon.Collection();
4 var model = new Falcon.Model();
5 var view = new Falcon.View();
6 var adapter = new Falcon.Adapter();
7
8 console.log( Falcon.isCollection(array) );// false
9 console.log( Falcon.isCollection(object) );// false
10 console.log( Falcon.isCollection(model) );// false
11 console.log( Falcon.isCollection(collection) ); // true
12 console.log( Falcon.isCollection(view) );// false
13 console.log( Falcon.isCollection(adapter) );// false
isDataObject
Falcon.isDataObject( object )
Boolean
Is the object a DataObject (Model or Collection)?
Method used to test if an object is a Falcon Model or Collection
- object
- The Object to test
1 var array = [];
2 var object = new Falcon.Object();
3 var collection = new Falcon.Collection();
4 var model = new Falcon.Model();
5 var view = new Falcon.View();
6 var adapter = new Falcon.Adapter();
7
8 console.log( Falcon.isDataObject(array) );// false
9 console.log( Falcon.isDataObject(object) );// false
10 console.log( Falcon.isDataObject(model) );// true
11 console.log( Falcon.isDataObject(collection) ); // true
12 console.log( Falcon.isDataObject(view) );// false
13 console.log( Falcon.isDataObject(adapter) );// false
Method used to test if an object is a Falcon Model, View, or Collection.
- object
- The Object to test
1 var array = [];
2 var object = new Falcon.Object();
3 var collection = new Falcon.Collection();
4 var model = new Falcon.Model();
5 var view = new Falcon.View();
6 var adapter = new Falcon.Adapter();
7
8 console.log( Falcon.isFalconObject(array) );// false
9 console.log( Falcon.isFalconObject(object) );// true
10 console.log( Falcon.isFalconObject(model) );// true
11 console.log( Falcon.isFalconObject(collection) ); // true
12 console.log( Falcon.isFalconObject(view) );// true
13 console.log( Falcon.isFalconObject(adapter) );// true
Method used to test if an object is a Falcon Model.
- object
- The Object to test
1 var array = [];
2 var object = new Falcon.Object();
3 var collection = new Falcon.Collection();
4 var model = new Falcon.Model();
5 var view = new Falcon.View();
6 var adapter = new Falcon.Adapter();
7
8 console.log( Falcon.isModel(array) );// false
9 console.log( Falcon.isModel(object) );// false
10 console.log( Falcon.isModel(model) );// true
11 console.log( Falcon.isModel(collection) ); // false
12 console.log( Falcon.isModel(view) );// false
13 console.log( Falcon.isModel(adapter) );// false
Method used to test if an object is a Falcon View.
- object
- The Object to test
1 var array = [];
2 var object = new Falcon.Object();
3 var collection = new Falcon.Collection();
4 var model = new Falcon.Model();
5 var view = new Falcon.View();
6 var adapter = new Falcon.Adapter();
7
8 console.log( Falcon.isView(array) );// false
9 console.log( Falcon.isView(object) );// false
10 console.log( Falcon.isView(model) );// false
11 console.log( Falcon.isView(collection) ); // false
12 console.log( Falcon.isView(view) );// true
13 console.log( Falcon.isView(adapter) );// false