SlideShare a Scribd company logo
Knockout js
special topic
hello!
I am Damon Hung Tran
I am here to present how data source and data binding
work on knockout js.
You can find me at hungtran.ninja
1.
Basic concepts
Let’s start with some classic theories
broken window
A criminological theory that a small damage will
lead to a system corruption.
Why we need a js framework
Js framework would keep your code nice and organized.
Approach right way
Most of the effort we spend on code without no organized, you will
have to spend double effort to fixing it.
““Code chạy được chưa chắc được
chạy.”
-Nguyễn Thế Điền (A squad lead in my team)
Material to used in this presentation
✘ Example knockout training project GIT:
https://gitlab.com/damon.hung.tran/knockout_traning
✘ Documentation official about knockout js:
○ http://knockoutjs.com/documentation/click-binding.html
○ http://knockoutjs.com/documentation.html
The basic OOP we apply in knockout js
Our process look like below
Backend
Datasource
handle
data logic
Frontend
Databinding
handle UI
logic
Data Binding
Data binding is the process of connecting
application user interface (UI) to a data
object (code). It enables changes
propagation by reflecting UI modifications in
the code and vise versa.
( function ($) ){
$(function(){
ko.smartboxSelectorUI = function (){
//Here is a constructor
var self = this; // save the current object
self.viewModelProperty = {}; //global property in this model
self.functionWriteHere = function (data, e){ // do something};
}
ko.applyBindings(new ko.smartboxSelectorUI(), (#“the element that you wanna binding
to”)[0]);
}
)}
Knockout view model UI
Datasource
Support the CRUD
(insert,read,update,delete)
data operations .
Only and only handle logic
about data.
Never, never and ever
make the UI logic in here.
Backend
Datasource
handle
data logic
( function ($) ){
$(function(){
Var smartboxSelectorData = function (){
Return {
getProducts:
function(){
// make a request to SERVER
}
}
}
}
)}
The result of response should organized like below:
{ status: 1,
errorCode: ‘ERR_CODE’,
Message: ‘some message’,
Result: { // data that server returned] }
Knockout view model Data
Function context:
$.ajax({
Url: ,
Type:,
dataType: “json”,
Success: function (response){
if(response.errorCode != 0){
//return success data
// no UI handle in here, Break process,
DUDE, DUDE!!!
// in some specific cases impossible to keep the rule,
you can break it. But in mindset DO NOT do it.
}
}
});
Benefit when approach js framework right way to
system
Easier to find
problem
Errors
Easier to
maintain +
improvement
What did we
discuss
today?
Let’s review some concepts
Why we need a js framework
Datasource and databind concept
Datasource in knockout js
Broken Window Theory
Approach right way to use js framework
Code example apply what I talked in this presentation
Data binding in knockout js
The benefit when organize good system
thanks!
Any questions?
You can find me at
damonhungtran.ninja
Credits
Special thanks to all the people who made and released
these awesome resources for free:
✘ Presentation template by SlidesCarnival
✘ Photographs by WallHaven
✘ Concept and Spirit idea by tuhoang
Ad

Recommended

10 ways to make your code rock
10 ways to make your code rock
martincronje
 
React.js 20150828
React.js 20150828
LearningTech
 
Font size
Font size
teampigeon
 
Running ms sql stored procedures in mule
Running ms sql stored procedures in mule
AnilKumar Etagowni
 
Responsive Views with Knockout
Responsive Views with Knockout
Engage Software
 
Knockout.js presentation
Knockout.js presentation
Scott Messinger
 
javascript code for mysql database connection
javascript code for mysql database connection
Hitesh Kumar Markam
 
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
SAS_Forum_2015_Data_Visualisation_With_HighCharts_D3
Vasilij Nevlev
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
Fwdays
 
handout-05b
handout-05b
tutorialsruby
 
Javascript and DOM
Javascript and DOM
Brian Moschel
 
The secret sauce behind {binding} in xaml
The secret sauce behind {binding} in xaml
brendonpage
 
Taking Web Apps Offline
Taking Web Apps Offline
Pedro Morais
 
Mvvmintroduction 130725124207-phpapp01
Mvvmintroduction 130725124207-phpapp01
Nguyen Cuong
 
Building decentralised apps with js - Devoxx Morocco 2018
Building decentralised apps with js - Devoxx Morocco 2018
Mikhail Kuznetcov
 
Workers
Workers
Adrian Caetano
 
Jquery.Tmpl
Jquery.Tmpl
LearningTech
 
Java script cookies
Java script cookies
AbhishekMondal42
 
Save your data
Save your data
fragphace
 
Knockout js
Knockout js
LearningTech
 
Backbone js in drupal core
Backbone js in drupal core
Marcin Wosinek
 
Create a Core Data Observer in 10mins
Create a Core Data Observer in 10mins
zmcartor
 
Django - Know Your Namespace: Middleware
Django - Know Your Namespace: Middleware
howiworkdaily
 
#İstSec'17 Out of Band Sql Injection Attacks
#İstSec'17 Out of Band Sql Injection Attacks
BGA Cyber Security
 
Sql Considered Harmful
Sql Considered Harmful
coderanger
 
Popup
Popup
Qamar Uddin
 
Data repositories
Data repositories
Corneil du Plessis
 
Knockout js
Knockout js
LearningTech
 
Knockout js session
Knockout js session
Ravinder Mahajan
 
Fundaments of Knockout js
Fundaments of Knockout js
Flavius-Radu Demian
 

More Related Content

What's hot (19)

Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
Fwdays
 
handout-05b
handout-05b
tutorialsruby
 
Javascript and DOM
Javascript and DOM
Brian Moschel
 
The secret sauce behind {binding} in xaml
The secret sauce behind {binding} in xaml
brendonpage
 
Taking Web Apps Offline
Taking Web Apps Offline
Pedro Morais
 
Mvvmintroduction 130725124207-phpapp01
Mvvmintroduction 130725124207-phpapp01
Nguyen Cuong
 
Building decentralised apps with js - Devoxx Morocco 2018
Building decentralised apps with js - Devoxx Morocco 2018
Mikhail Kuznetcov
 
Workers
Workers
Adrian Caetano
 
Jquery.Tmpl
Jquery.Tmpl
LearningTech
 
Java script cookies
Java script cookies
AbhishekMondal42
 
Save your data
Save your data
fragphace
 
Knockout js
Knockout js
LearningTech
 
Backbone js in drupal core
Backbone js in drupal core
Marcin Wosinek
 
Create a Core Data Observer in 10mins
Create a Core Data Observer in 10mins
zmcartor
 
Django - Know Your Namespace: Middleware
Django - Know Your Namespace: Middleware
howiworkdaily
 
#İstSec'17 Out of Band Sql Injection Attacks
#İstSec'17 Out of Band Sql Injection Attacks
BGA Cyber Security
 
Sql Considered Harmful
Sql Considered Harmful
coderanger
 
Popup
Popup
Qamar Uddin
 
Data repositories
Data repositories
Corneil du Plessis
 
Кирилл Латыш "ERP on Websockets"
Кирилл Латыш "ERP on Websockets"
Fwdays
 
The secret sauce behind {binding} in xaml
The secret sauce behind {binding} in xaml
brendonpage
 
Taking Web Apps Offline
Taking Web Apps Offline
Pedro Morais
 
Mvvmintroduction 130725124207-phpapp01
Mvvmintroduction 130725124207-phpapp01
Nguyen Cuong
 
Building decentralised apps with js - Devoxx Morocco 2018
Building decentralised apps with js - Devoxx Morocco 2018
Mikhail Kuznetcov
 
Save your data
Save your data
fragphace
 
Backbone js in drupal core
Backbone js in drupal core
Marcin Wosinek
 
Create a Core Data Observer in 10mins
Create a Core Data Observer in 10mins
zmcartor
 
Django - Know Your Namespace: Middleware
Django - Know Your Namespace: Middleware
howiworkdaily
 
#İstSec'17 Out of Band Sql Injection Attacks
#İstSec'17 Out of Band Sql Injection Attacks
BGA Cyber Security
 
Sql Considered Harmful
Sql Considered Harmful
coderanger
 

Similar to How my team is applying JS framework for PHP projects. (20)

Knockout js
Knockout js
LearningTech
 
Knockout js session
Knockout js session
Ravinder Mahajan
 
Fundaments of Knockout js
Fundaments of Knockout js
Flavius-Radu Demian
 
Knockout Introduction
Knockout Introduction
Sarvesh Kushwaha
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
Knockout js
Knockout js
Andrey Kolodnitsky
 
KnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
Introduction to Knockout Js
Introduction to Knockout Js
Knoldus Inc.
 
KnockOutjs from Scratch
KnockOutjs from Scratch
Udaya Kumar
 
Knockoutjs
Knockoutjs
Karthik Sathyanarayanan
 
Knockout in action
Knockout in action
Gerardo Leyes
 
KnockoutJS and MVVM
KnockoutJS and MVVM
Manvendra Singh
 
Knockout
Knockout
LearningTech
 
Knockout js (Dennis Haney)
Knockout js (Dennis Haney)
JavaScript Meetup HCMC
 
Bringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
Knockoutjs
Knockoutjs
Yourcontent YC
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
Knock out Introduction with samples (jsfiddle.net)
Knock out Introduction with samples (jsfiddle.net)
Balakrishnanan Ganesan
 
Knockout.js
Knockout.js
Vivek Rajan
 
Intro to Knockout
Intro to Knockout
John Maxwell
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
KnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
Introduction to Knockout Js
Introduction to Knockout Js
Knoldus Inc.
 
KnockOutjs from Scratch
KnockOutjs from Scratch
Udaya Kumar
 
Bringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
Knock out Introduction with samples (jsfiddle.net)
Knock out Introduction with samples (jsfiddle.net)
Balakrishnanan Ganesan
 
Ad

Recently uploaded (20)

Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
The Anti-Masterclass Live - Peak of Data & AI 2025
The Anti-Masterclass Live - Peak of Data & AI 2025
Safe Software
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Introduction to Agile Frameworks for Product Managers.pdf
Introduction to Agile Frameworks for Product Managers.pdf
Ali Vahed
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
The Anti-Masterclass Live - Peak of Data & AI 2025
The Anti-Masterclass Live - Peak of Data & AI 2025
Safe Software
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
How Automation in Claims Handling Streamlined Operations
How Automation in Claims Handling Streamlined Operations
Insurance Tech Services
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
Heat Treatment Process Automation in India
Heat Treatment Process Automation in India
Reckers Mechatronics
 
Open Source Software Development Methods
Open Source Software Development Methods
VICTOR MAESTRE RAMIREZ
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
From Data Preparation to Inference: How Alluxio Speeds Up AI
From Data Preparation to Inference: How Alluxio Speeds Up AI
Alluxio, Inc.
 
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Test Case Design Techniques – Practical Examples & Best Practices in Software...
Muhammad Fahad Bashir
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Ad

How my team is applying JS framework for PHP projects.

  • 2. hello! I am Damon Hung Tran I am here to present how data source and data binding work on knockout js. You can find me at hungtran.ninja
  • 3. 1. Basic concepts Let’s start with some classic theories
  • 4. broken window A criminological theory that a small damage will lead to a system corruption.
  • 5. Why we need a js framework Js framework would keep your code nice and organized.
  • 6. Approach right way Most of the effort we spend on code without no organized, you will have to spend double effort to fixing it.
  • 7. ““Code chạy được chưa chắc được chạy.” -Nguyễn Thế Điền (A squad lead in my team)
  • 8. Material to used in this presentation ✘ Example knockout training project GIT: https://gitlab.com/damon.hung.tran/knockout_traning ✘ Documentation official about knockout js: ○ http://knockoutjs.com/documentation/click-binding.html ○ http://knockoutjs.com/documentation.html
  • 9. The basic OOP we apply in knockout js Our process look like below Backend Datasource handle data logic Frontend Databinding handle UI logic
  • 10. Data Binding Data binding is the process of connecting application user interface (UI) to a data object (code). It enables changes propagation by reflecting UI modifications in the code and vise versa.
  • 11. ( function ($) ){ $(function(){ ko.smartboxSelectorUI = function (){ //Here is a constructor var self = this; // save the current object self.viewModelProperty = {}; //global property in this model self.functionWriteHere = function (data, e){ // do something}; } ko.applyBindings(new ko.smartboxSelectorUI(), (#“the element that you wanna binding to”)[0]); } )} Knockout view model UI
  • 12. Datasource Support the CRUD (insert,read,update,delete) data operations . Only and only handle logic about data. Never, never and ever make the UI logic in here. Backend Datasource handle data logic
  • 13. ( function ($) ){ $(function(){ Var smartboxSelectorData = function (){ Return { getProducts: function(){ // make a request to SERVER } } } } )} The result of response should organized like below: { status: 1, errorCode: ‘ERR_CODE’, Message: ‘some message’, Result: { // data that server returned] } Knockout view model Data Function context: $.ajax({ Url: , Type:, dataType: “json”, Success: function (response){ if(response.errorCode != 0){ //return success data // no UI handle in here, Break process, DUDE, DUDE!!! // in some specific cases impossible to keep the rule, you can break it. But in mindset DO NOT do it. } } });
  • 14. Benefit when approach js framework right way to system Easier to find problem Errors Easier to maintain + improvement
  • 16. Let’s review some concepts Why we need a js framework Datasource and databind concept Datasource in knockout js Broken Window Theory Approach right way to use js framework Code example apply what I talked in this presentation Data binding in knockout js The benefit when organize good system
  • 17. thanks! Any questions? You can find me at damonhungtran.ninja
  • 18. Credits Special thanks to all the people who made and released these awesome resources for free: ✘ Presentation template by SlidesCarnival ✘ Photographs by WallHaven ✘ Concept and Spirit idea by tuhoang

Editor's Notes

  • #5: A good programmer know how to get to job well and fast without use any js framework. But let thinking when the system grown, with 1000 lines of code in each of features with no organized. The hidden, remaining bugs become a big monster.
  • #7: The OOP in javascript is best practice in here.