SlideShare a Scribd company logo
1 of 22
Alloy + Backbone.js =
AWESOME!!!!!!!!!!!!
• Owner of Eccra Solutions, LLC.
• 15 years experience in development/consulting
• Specialize in Mobile Development
• Focusing on Ruby on Rails, Appcelerator, Objective C, Java, & NodeJs
• Member of the Appcelerator Titan Program & TCAD
• Loves Indie Music, Food and the Reds (Liverpool & Cincinnati)
• Twitter: @Eccra
• URL: www.eccra.com
• GitHub: bradenpowers
Who am I?
Backbone.js gives structure to web applications by
providing models with key-value binding and custom
events, collections with a rich API of enumerable
functions,views with declarative event handling, and
connects it all to your existing API over a RESTful JSON
interface.
What is Backbone?
Wait a minute
• This is a mobile app, not a web app. How do we use it?
• Don’t worry...It is cooked into Alloy
How do I get started?
CreateYour Model
Presto...Your Model is Created!
exports.definition = {
config: {
columns: {
"city": "string",
"name": "string"
},
adapter: {
type: "sql",
collection_name: "baseball"
}
},
extendModel: function(Model) {
_.extend(Model.prototype, {
// extended functions and properties go
here
});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {
// extended functions and properties go
here
});
return Collection;
}
What If I Have A Database That I
Want To Use?
exports.definition = {
config: {
"adapter": {
"type": "sql",
"collection_name": "baseball",
"db_file": "/baseball.sqlite",
"idAttribute": "id",
"remoteBackup": false
}
},
extendModel: function(Model) {
_.extend(Model.prototype, {
// extended functions and properties go
here
});
return Model;
},
extendCollection: function(Collection) {
_.extend(Collection.prototype, {
// extended functions and properties go
here
});
return Collection;
}
}
What If I Have A REST API That
I Want To Use?
exports.definition = {
config: {
adapter: {
type: "baseball_rest",
collection_name: "baseball",
base_url: 'YourURL/baseball'
}
},
extendModel: function(Model) {
// Mongo uses _id as the model ID
_.extend(Model.prototype, {
idAttribute: '_id'
});
return Model;
}
}
* Please note that you have to build your own REST API for this to work! That is a
ton of fun and I don’t have enough time to talk about it here.
So...How Do I Use My Model?
MAGIC!! (not really)
EditYour Alloy.js File SoYou Can
Use It Globally!
Alloy.Collections.baseball = Alloy.createCollection('baseball');
Time to Edit the Index.js File To
Grab that Data!
var teams = Alloy.Collections.baseball;
teams.fetch();
$.index.open();
What is that “fetch thing? “ Fetch is what is used to bind the collection to the
TableView.
Now Let’s Edit the
View...Index.xml
<Alloy>
<Window class="container">
<TableView id="table" dataCollection="baseball">
<Require src="row"></Require>
</TableView>
</Window>
</Alloy>
How Does The Data Get Into
The TableView?
The Use Of BackBone Sync
Adapters
• FOR A COLLECTION
• FETCH - Grabs the Data
• CREATE - New or Updates
• DESTROY - Deletes
• FOR A MODEL
• FETCH - Grabs the Data
• SAVE - New or Updates
• DESTROY - Deletes
What Else Can I Do With Sync
Adapters?
• Custom Sync Adapter (for your REST API)
• Queries for the SQL Adapter
• Migrations (SQL only)
OK...Back To The Program...How
Is That Data Getting Into the
TableView?
Time To Create the Row.xml
That We Required in Index.Xml
<Alloy>
<TableViewRow>
<Label id="city" text="{city}"/>
<Label id="name" text="{name}"/>
</TableViewRow>
</Alloy>
The data in the { } is the data bound from
the collection.
Time To Edit The Row
Controller...Row.js
if ($model) {
$.row.model = $model.toJSON();
}
So When I Finally Run the Code
I See This!
OK...That Is Awesome...What If
I Want to Add Another Team?
function addBaseBallTeam(e) {
var model = Alloy.createModel('baseball', {
city: $.cityText.value,
name: $.nameText.value
});
// add model to the collection and save it to sqlite and then
refresh the data
team.add(model);
model.save();
team.fetch();
}
Now What? What Else Is There?
• Data Binding - Filtering
• Extending Backbone (likeValidation)
Thanks!

More Related Content

What's hot

SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
Sébastien Levert
 
Orgchart for Alfresco lightning talk
Orgchart for Alfresco lightning talkOrgchart for Alfresco lightning talk
Orgchart for Alfresco lightning talk
ITD Systems
 
Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)
AmedJacobReza
 

What's hot (20)

Testing AngularJS
Testing AngularJSTesting AngularJS
Testing AngularJS
 
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
SharePoint Saturday Lisbon 2017 - SharePoint Framework, Angular & Azure Funct...
 
Rails for Django developers
Rails for Django developersRails for Django developers
Rails for Django developers
 
Ext Web Components - Dev Week 2019
Ext Web Components - Dev Week 2019Ext Web Components - Dev Week 2019
Ext Web Components - Dev Week 2019
 
Creating BananaJS with Angular 2, Angular CLI, and Material Design
Creating BananaJS with Angular 2, Angular CLI, and Material DesignCreating BananaJS with Angular 2, Angular CLI, and Material Design
Creating BananaJS with Angular 2, Angular CLI, and Material Design
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
 
Getting Started with the Angular 2 CLI
Getting Started with the Angular 2 CLIGetting Started with the Angular 2 CLI
Getting Started with the Angular 2 CLI
 
Orgchart for Alfresco lightning talk
Orgchart for Alfresco lightning talkOrgchart for Alfresco lightning talk
Orgchart for Alfresco lightning talk
 
Micro frontend
Micro frontendMicro frontend
Micro frontend
 
Alloy Simple App Demonstration
Alloy Simple App DemonstrationAlloy Simple App Demonstration
Alloy Simple App Demonstration
 
Appcelerator Titanium Alloy
Appcelerator Titanium Alloy Appcelerator Titanium Alloy
Appcelerator Titanium Alloy
 
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
 
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
Angular2 + Ng-Lightning + Lightning Design System = Great AppsAngular2 + Ng-Lightning + Lightning Design System = Great Apps
Angular2 + Ng-Lightning + Lightning Design System = Great Apps
 
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 MinutesUsing Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
 
Angular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHEREAngular elements - embed your angular components EVERYWHERE
Angular elements - embed your angular components EVERYWHERE
 
Get Hip with Java Hipster - JavaOne 2017
Get Hip with Java Hipster - JavaOne 2017Get Hip with Java Hipster - JavaOne 2017
Get Hip with Java Hipster - JavaOne 2017
 
Why you should add React to your Rails application now!
Why you should add React to your Rails application now!Why you should add React to your Rails application now!
Why you should add React to your Rails application now!
 
How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...
How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...
How to create an angular 2.0 application in liferay dxp to fetch the ootb adv...
 
Develop Hip APIs and Apps with Spring Boot and Angular - Connect.Tech 2017
 Develop Hip APIs and Apps with Spring Boot and Angular - Connect.Tech 2017 Develop Hip APIs and Apps with Spring Boot and Angular - Connect.Tech 2017
Develop Hip APIs and Apps with Spring Boot and Angular - Connect.Tech 2017
 
Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)
 

Similar to Alloy backbone

Intro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptIntro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate Javascript
Andrew Lovett-Barron
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar
 
Pablo Villalba -
Pablo Villalba - Pablo Villalba -
Pablo Villalba -
.toster
 

Similar to Alloy backbone (20)

Riding the Edge with Ember.js
Riding the Edge with Ember.jsRiding the Edge with Ember.js
Riding the Edge with Ember.js
 
Introduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.ioIntroduction to Ember.js and how we used it at FlowPro.io
Introduction to Ember.js and how we used it at FlowPro.io
 
Intro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate JavascriptIntro to BackboneJS + Intermediate Javascript
Intro to BackboneJS + Intermediate Javascript
 
Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012Backbonification for dummies - Arrrrug 10/1/2012
Backbonification for dummies - Arrrrug 10/1/2012
 
Web Development using Ruby on Rails
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
 
From Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) AgainFrom Backbone to Ember and Back(bone) Again
From Backbone to Ember and Back(bone) Again
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Core Data in RubyMotion #inspect
Core Data in RubyMotion #inspectCore Data in RubyMotion #inspect
Core Data in RubyMotion #inspect
 
Building a Single Page Application with VueJS
Building a Single Page Application with VueJSBuilding a Single Page Application with VueJS
Building a Single Page Application with VueJS
 
Boosting Your Productivity, with Backbone & RactiveJS
Boosting Your Productivity, with Backbone & RactiveJS Boosting Your Productivity, with Backbone & RactiveJS
Boosting Your Productivity, with Backbone & RactiveJS
 
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021Get Hip with JHipster - Colorado Springs Open Source User Group 2021
Get Hip with JHipster - Colorado Springs Open Source User Group 2021
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 
Mobile native-hacks
Mobile native-hacksMobile native-hacks
Mobile native-hacks
 
Play Framework: Intro & High-Level Overview
Play Framework: Intro & High-Level OverviewPlay Framework: Intro & High-Level Overview
Play Framework: Intro & High-Level Overview
 
Angular js
Angular jsAngular js
Angular js
 
Intro to Rails
Intro to RailsIntro to Rails
Intro to Rails
 
frontend-161011205424.pptx
frontend-161011205424.pptxfrontend-161011205424.pptx
frontend-161011205424.pptx
 
Oracle APEX Nitro
Oracle APEX NitroOracle APEX Nitro
Oracle APEX Nitro
 
Scaling with swagger
Scaling with swaggerScaling with swagger
Scaling with swagger
 
Pablo Villalba -
Pablo Villalba - Pablo Villalba -
Pablo Villalba -
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Recently uploaded (20)

WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 

Alloy backbone

  • 1. Alloy + Backbone.js = AWESOME!!!!!!!!!!!!
  • 2. • Owner of Eccra Solutions, LLC. • 15 years experience in development/consulting • Specialize in Mobile Development • Focusing on Ruby on Rails, Appcelerator, Objective C, Java, & NodeJs • Member of the Appcelerator Titan Program & TCAD • Loves Indie Music, Food and the Reds (Liverpool & Cincinnati) • Twitter: @Eccra • URL: www.eccra.com • GitHub: bradenpowers Who am I?
  • 3. Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions,views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface. What is Backbone?
  • 4. Wait a minute • This is a mobile app, not a web app. How do we use it? • Don’t worry...It is cooked into Alloy
  • 5. How do I get started?
  • 7. Presto...Your Model is Created! exports.definition = { config: { columns: { "city": "string", "name": "string" }, adapter: { type: "sql", collection_name: "baseball" } }, extendModel: function(Model) { _.extend(Model.prototype, { // extended functions and properties go here }); return Model; }, extendCollection: function(Collection) { _.extend(Collection.prototype, { // extended functions and properties go here }); return Collection; }
  • 8. What If I Have A Database That I Want To Use? exports.definition = { config: { "adapter": { "type": "sql", "collection_name": "baseball", "db_file": "/baseball.sqlite", "idAttribute": "id", "remoteBackup": false } }, extendModel: function(Model) { _.extend(Model.prototype, { // extended functions and properties go here }); return Model; }, extendCollection: function(Collection) { _.extend(Collection.prototype, { // extended functions and properties go here }); return Collection; } }
  • 9. What If I Have A REST API That I Want To Use? exports.definition = { config: { adapter: { type: "baseball_rest", collection_name: "baseball", base_url: 'YourURL/baseball' } }, extendModel: function(Model) { // Mongo uses _id as the model ID _.extend(Model.prototype, { idAttribute: '_id' }); return Model; } } * Please note that you have to build your own REST API for this to work! That is a ton of fun and I don’t have enough time to talk about it here.
  • 10. So...How Do I Use My Model? MAGIC!! (not really)
  • 11. EditYour Alloy.js File SoYou Can Use It Globally! Alloy.Collections.baseball = Alloy.createCollection('baseball');
  • 12. Time to Edit the Index.js File To Grab that Data! var teams = Alloy.Collections.baseball; teams.fetch(); $.index.open(); What is that “fetch thing? “ Fetch is what is used to bind the collection to the TableView.
  • 13. Now Let’s Edit the View...Index.xml <Alloy> <Window class="container"> <TableView id="table" dataCollection="baseball"> <Require src="row"></Require> </TableView> </Window> </Alloy> How Does The Data Get Into The TableView?
  • 14. The Use Of BackBone Sync Adapters • FOR A COLLECTION • FETCH - Grabs the Data • CREATE - New or Updates • DESTROY - Deletes • FOR A MODEL • FETCH - Grabs the Data • SAVE - New or Updates • DESTROY - Deletes
  • 15. What Else Can I Do With Sync Adapters? • Custom Sync Adapter (for your REST API) • Queries for the SQL Adapter • Migrations (SQL only)
  • 16. OK...Back To The Program...How Is That Data Getting Into the TableView?
  • 17. Time To Create the Row.xml That We Required in Index.Xml <Alloy> <TableViewRow> <Label id="city" text="{city}"/> <Label id="name" text="{name}"/> </TableViewRow> </Alloy> The data in the { } is the data bound from the collection.
  • 18. Time To Edit The Row Controller...Row.js if ($model) { $.row.model = $model.toJSON(); }
  • 19. So When I Finally Run the Code I See This!
  • 20. OK...That Is Awesome...What If I Want to Add Another Team? function addBaseBallTeam(e) { var model = Alloy.createModel('baseball', { city: $.cityText.value, name: $.nameText.value }); // add model to the collection and save it to sqlite and then refresh the data team.add(model); model.save(); team.fetch(); }
  • 21. Now What? What Else Is There? • Data Binding - Filtering • Extending Backbone (likeValidation)