SlideShare una empresa de Scribd logo
1 de 43
Descargar para leer sin conexión
Lipstick on a Magical Pony:*
dynamic web pages without JS
  +
Tim Bell
timothybell@gmail.com
@timb07
*Title borrowed from Alaa’s talk last month
Problem
Your magical pony looks a bit plain.
2 / 21
Problem
Your magical pony looks a bit plain.
2 / 21
Problem
Your magical pony looks a bit plain.
doing whole page loads is so last decade
2 / 21
Problem
Your magical pony looks a bit plain.
doing whole page loads is so last decade
but you don't like Javascript
2 / 21
Problem
Your magical pony looks a bit plain.
doing whole page loads is so last decade
but you don't like Javascript
What to do??? 2 / 21
Solution
Lipstick!
3 / 21
Solution
Lipstick!
3 / 21
Solution
Lipstick!
Intercooler.js!
4 / 21
Solution
Lipstick!
Intercooler.js!
HTTP requests via AJAX in response to events
Response replaces contents of element
Specified by HTTP element attributes, not Javascript
4 / 21
Solution
Lipstick!
Intercooler.js!
HTTP requests via AJAX in response to events
Response replaces contents of element
Specified by HTTP element attributes, not Javascript
Example:
<a ic-post-to="/button_click">Click Me!</a>
4 / 21
Issues
Intercooler is backend-agnostic
5 / 21
Issues
Intercooler is backend-agnostic
… but Django has certain expectations
5 / 21
Issues
Intercooler is backend-agnostic
… but Django has certain expectations
URLs end in '/' (matters for POST requests)
CSRF protection for POST requests
5 / 21
Issues
Intercooler is backend-agnostic
… but Django has certain expectations
URLs end in '/' (matters for POST requests)
CSRF protection for POST requests
Better example:
<a ic-get-from="/button_click/">Click Me!</a>
5 / 21
Issues
Intercooler is backend-agnostic
… but Django has certain expectations
URLs end in '/' (matters for POST requests)
CSRF protection for POST requests
Better example:
<a ic-get-from="/button_click/">Click Me!</a>
Or (using Django template):
<a ic-get-from="{% url 'button-click' %}">Click Me!</a>
5 / 21
Django backend
urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('button_click/', views.button_click_view, name='button-click'),
]
views.py:
from django.http import HttpResponse
def button_click_view(request):
return HttpResponse('You Clicked Me!')
6 / 21
Django backend
urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('button_click/', views.button_click_view, name='button-click'),
]
views.py:
from django.http import HttpResponse
def button_click_view(request):
return HttpResponse('You Clicked Me!')
Result:
<a ic-get-from="/button_click/">You Clicked Me!</a>
6 / 21
WOW!!!!!!
7 / 21
WOW!!!!!!
I thought you promised lipstick…
7 / 21
WOW!!!!!!
I thought you promised lipstick…
Trivial example is trivial
7 / 21
WOW!!!!!!
I thought you promised lipstick…
Trivial example is trivial
What about…
Request inputs (form data, etc.)?
Response handling?
DOM and styling changes?
Data dependencies?
7 / 21
Intercooler features
8 / 21
Intercooler features
HTTP verbs:
ic-get-from, ic-post-to
ic-delete-from, ic-patch-to, ic-put-to
Variants: ic-append-from, ic-prepend-from
8 / 21
Intercooler features
HTTP verbs:
ic-get-from, ic-post-to
ic-delete-from, ic-patch-to, ic-put-to
Variants: ic-append-from, ic-prepend-from
Target selection:
ic-target, ic-replace-target
8 / 21
Intercooler features
HTTP verbs:
ic-get-from, ic-post-to
ic-delete-from, ic-patch-to, ic-put-to
Variants: ic-append-from, ic-prepend-from
Target selection:
ic-target, ic-replace-target
DOM manipulation:
ic-add-class, ic-remove-class, ic-remove-after
8 / 21
Intercooler features
HTTP verbs:
ic-get-from, ic-post-to
ic-delete-from, ic-patch-to, ic-put-to
Variants: ic-append-from, ic-prepend-from
Target selection:
ic-target, ic-replace-target
DOM manipulation:
ic-add-class, ic-remove-class, ic-remove-after
Dependencies:
ic-deps, ic-src, implied dependencies
8 / 21
Intercooler features
HTTP verbs:
ic-get-from, ic-post-to
ic-delete-from, ic-patch-to, ic-put-to
Variants: ic-append-from, ic-prepend-from
Target selection:
ic-target, ic-replace-target
DOM manipulation:
ic-add-class, ic-remove-class, ic-remove-after
Dependencies:
ic-deps, ic-src, implied dependencies
And more!
8 / 21
Triggering Intercooler requests
Intercooler uses the "natural" event for an element to trigger a request:
For form elements, issue the request on the submit event.
For input elements except buttons, issue the request on the change event.
For all other elements, including buttons, issue the request on the click event.
9 / 21
Triggering Intercooler requests
Intercooler uses the "natural" event for an element to trigger a request:
For form elements, issue the request on the submit event.
For input elements except buttons, issue the request on the change event.
For all other elements, including buttons, issue the request on the click event.
Other triggers can be specified using ic-trigger-from or ic-trigger-on.
9 / 21
Example: form eld validation
Validate an email address when it changes
10 / 21
Example: form eld validation
Invalid email address
11 / 21
Example: form eld validation
Email address already used
12 / 21
Example: form eld validation
Success!
13 / 21
Example: form eld validation
template: inlinevalidation.html
<form>
{% csrf_token %}
{% include 'examples/email_address_form_group.html' %}
<button class="btn btn-default">Submit</button>
</form>
14 / 21
Example: form eld validation
template: email_address_form_group.html
<div class="form-group {{ form_group_class }}">
<label class="control-label">
Email Address
</label>
<input class="form-control" name="email"
ic-post-to="{% url 'contact-email' %}" ic-target="closest div" ic-replace-target="true"
value="{{ email }}"
>
{% if error_message %}
<span class="help-block text-error">{{ error_message }}</span>
{% endif %}
</div>
15 / 21
Example: form eld validation
view:
from django.core.validators import validate_email, ValidationError
def contact_email_view(request):
email = request.POST['email']
context = {'email': email}
try:
validate_email(email)
except ValidationError:
context['error_message'] = "Please enter a valid email address"
else:
if email != "test@test.com":
context['error_message'] = "That email is already taken. Please enter another email."
else:
context['form_group_class'] = "has-success"
if 'error_message' in context:
context['form_group_class'] = "has-error"
return render(request, 'examples/email_address_form_group.html', context=context)
16 / 21
17 / 21
Philosophy
It can be easy for some developers to dismiss intercooler as overly simple
and an archaic way of building web applications. This is intellectually lazy.
Intercooler is a tool for returning to the original network architecture of the
web. Using HTML as the data transport in communication with a server is
what enables HATEOAS, the core distinguishing feature of that network
architecture. Intercooler goes with the grain of the web, rather than forcing
a more traditional thick-client model onto it, thereby avoiding the
complexity and security issues that come along with that model.
Yes, intercooler is simple, but it is a deceptive simplicity, very much like the
early web.
http://intercoolerjs.org/docs.html#philosophy
18 / 21
On Churn
Many javascript projects are updated at a dizzying pace. Intercooler is not.
This is not because it is dead, but rather because it is (mostly) right: the
basic idea is right, and the implementation at least right enough.
This means there will not be constant activity and churn on the project, but
rather a stewardship relationship: the main goal now is to not screw it up.
The documentation will be improved, tests will be added, small new
delarative features will be added around the edges, but there will be no
massive rewrite or constant updating. This is in contrast with the software
industry in general and the front end world in particular, which has
comical levels of churn.
Intercooler is a sturdy, reliable tool for web development.
http://intercoolerjs.org/docs.html#philosophy
19 / 21
Finally…
Your magical pony looks more magical.
20 / 21
Finally…
Your magical pony looks more magical.
20 / 21
Thanks!
http://intercoolerjs.org/
https://petercuret.com/add-ajax-to-django-without-writing-javascript/
21 / 21

Más contenido relacionado

La actualidad más candente

HTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4AfricaHTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4Africa
Robert Nyman
 
Introduction To ASP.Net MVC
Introduction To ASP.Net MVCIntroduction To ASP.Net MVC
Introduction To ASP.Net MVC
Joe Wilson
 
Angularjs Live Project
Angularjs Live ProjectAngularjs Live Project
Angularjs Live Project
Mohd Manzoor Ahmed
 

La actualidad más candente (11)

Aloha Presentation #t3con10
Aloha Presentation #t3con10Aloha Presentation #t3con10
Aloha Presentation #t3con10
 
CRUD with Dojo
CRUD with DojoCRUD with Dojo
CRUD with Dojo
 
Annotated controllers with Spring MVC 2.5
Annotated controllers with Spring MVC 2.5Annotated controllers with Spring MVC 2.5
Annotated controllers with Spring MVC 2.5
 
Desafios do Profissionalismo Ágil
Desafios do Profissionalismo ÁgilDesafios do Profissionalismo Ágil
Desafios do Profissionalismo Ágil
 
Best Laravel Eloquent Tips and Tricks
Best Laravel Eloquent Tips and TricksBest Laravel Eloquent Tips and Tricks
Best Laravel Eloquent Tips and Tricks
 
Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
 
HTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4AfricaHTML5, the open web, and what it means for you -Tech4Africa
HTML5, the open web, and what it means for you -Tech4Africa
 
Introduction To ASP.Net MVC
Introduction To ASP.Net MVCIntroduction To ASP.Net MVC
Introduction To ASP.Net MVC
 
Angularjs Live Project
Angularjs Live ProjectAngularjs Live Project
Angularjs Live Project
 
Fast by Default
Fast by DefaultFast by Default
Fast by Default
 
Lycos email login and reset steps
Lycos email login and reset steps Lycos email login and reset steps
Lycos email login and reset steps
 

Similar a Lipstick on a Magical Pony: dynamic web pages without Javascript

Adding a view
Adding a viewAdding a view
Adding a view
Nhan Do
 

Similar a Lipstick on a Magical Pony: dynamic web pages without Javascript (20)

Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14Polymer & the web components revolution 6:25:14
Polymer & the web components revolution 6:25:14
 
JavaScript and DOM Pattern Implementation
JavaScript and DOM Pattern ImplementationJavaScript and DOM Pattern Implementation
JavaScript and DOM Pattern Implementation
 
URL Hacking 101: An Easy Way to Streamline Processes in Salesforce
URL Hacking 101: An Easy Way to Streamline Processes in Salesforce URL Hacking 101: An Easy Way to Streamline Processes in Salesforce
URL Hacking 101: An Easy Way to Streamline Processes in Salesforce
 
]project-open[ Workflow Developer Tutorial Part 3
]project-open[ Workflow Developer Tutorial Part 3]project-open[ Workflow Developer Tutorial Part 3
]project-open[ Workflow Developer Tutorial Part 3
 
Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4Python Code Camp for Professionals 1/4
Python Code Camp for Professionals 1/4
 
Dojo1.0_Tutorials
Dojo1.0_TutorialsDojo1.0_Tutorials
Dojo1.0_Tutorials
 
2310 b 05
2310 b 052310 b 05
2310 b 05
 
Django crush course
Django crush course Django crush course
Django crush course
 
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
Introduction to Magento 2 module development - PHP Antwerp Meetup 2017
 
A Pocketful of Pro-tips
A Pocketful of Pro-tipsA Pocketful of Pro-tips
A Pocketful of Pro-tips
 
Track Report & Optimize Your Web Creations
Track Report & Optimize Your Web CreationsTrack Report & Optimize Your Web Creations
Track Report & Optimize Your Web Creations
 
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With DeadlinesJBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
JBUG 11 - Django-The Web Framework For Perfectionists With Deadlines
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
Angular JS2 Training Session #2
Angular JS2 Training Session #2Angular JS2 Training Session #2
Angular JS2 Training Session #2
 
Adding a view
Adding a viewAdding a view
Adding a view
 
Documentation vs test about cucumber but not only for vegetarians
Documentation vs test about cucumber but not only for vegetariansDocumentation vs test about cucumber but not only for vegetarians
Documentation vs test about cucumber but not only for vegetarians
 
Automated Detection of HPP Vulnerabilities in Web Applications Version 0.3, B...
Automated Detection of HPP Vulnerabilities in Web Applications Version 0.3, B...Automated Detection of HPP Vulnerabilities in Web Applications Version 0.3, B...
Automated Detection of HPP Vulnerabilities in Web Applications Version 0.3, B...
 
What is MVC?
What is MVC?What is MVC?
What is MVC?
 

Último

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Último (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Lipstick on a Magical Pony: dynamic web pages without Javascript

  • 1. Lipstick on a Magical Pony:* dynamic web pages without JS   + Tim Bell timothybell@gmail.com @timb07 *Title borrowed from Alaa’s talk last month
  • 2. Problem Your magical pony looks a bit plain. 2 / 21
  • 3. Problem Your magical pony looks a bit plain. 2 / 21
  • 4. Problem Your magical pony looks a bit plain. doing whole page loads is so last decade 2 / 21
  • 5. Problem Your magical pony looks a bit plain. doing whole page loads is so last decade but you don't like Javascript 2 / 21
  • 6. Problem Your magical pony looks a bit plain. doing whole page loads is so last decade but you don't like Javascript What to do??? 2 / 21
  • 10. Solution Lipstick! Intercooler.js! HTTP requests via AJAX in response to events Response replaces contents of element Specified by HTTP element attributes, not Javascript 4 / 21
  • 11. Solution Lipstick! Intercooler.js! HTTP requests via AJAX in response to events Response replaces contents of element Specified by HTTP element attributes, not Javascript Example: <a ic-post-to="/button_click">Click Me!</a> 4 / 21
  • 13. Issues Intercooler is backend-agnostic … but Django has certain expectations 5 / 21
  • 14. Issues Intercooler is backend-agnostic … but Django has certain expectations URLs end in '/' (matters for POST requests) CSRF protection for POST requests 5 / 21
  • 15. Issues Intercooler is backend-agnostic … but Django has certain expectations URLs end in '/' (matters for POST requests) CSRF protection for POST requests Better example: <a ic-get-from="/button_click/">Click Me!</a> 5 / 21
  • 16. Issues Intercooler is backend-agnostic … but Django has certain expectations URLs end in '/' (matters for POST requests) CSRF protection for POST requests Better example: <a ic-get-from="/button_click/">Click Me!</a> Or (using Django template): <a ic-get-from="{% url 'button-click' %}">Click Me!</a> 5 / 21
  • 17. Django backend urls.py: from django.urls import path from . import views urlpatterns = [ path('button_click/', views.button_click_view, name='button-click'), ] views.py: from django.http import HttpResponse def button_click_view(request): return HttpResponse('You Clicked Me!') 6 / 21
  • 18. Django backend urls.py: from django.urls import path from . import views urlpatterns = [ path('button_click/', views.button_click_view, name='button-click'), ] views.py: from django.http import HttpResponse def button_click_view(request): return HttpResponse('You Clicked Me!') Result: <a ic-get-from="/button_click/">You Clicked Me!</a> 6 / 21
  • 20. WOW!!!!!! I thought you promised lipstick… 7 / 21
  • 21. WOW!!!!!! I thought you promised lipstick… Trivial example is trivial 7 / 21
  • 22. WOW!!!!!! I thought you promised lipstick… Trivial example is trivial What about… Request inputs (form data, etc.)? Response handling? DOM and styling changes? Data dependencies? 7 / 21
  • 24. Intercooler features HTTP verbs: ic-get-from, ic-post-to ic-delete-from, ic-patch-to, ic-put-to Variants: ic-append-from, ic-prepend-from 8 / 21
  • 25. Intercooler features HTTP verbs: ic-get-from, ic-post-to ic-delete-from, ic-patch-to, ic-put-to Variants: ic-append-from, ic-prepend-from Target selection: ic-target, ic-replace-target 8 / 21
  • 26. Intercooler features HTTP verbs: ic-get-from, ic-post-to ic-delete-from, ic-patch-to, ic-put-to Variants: ic-append-from, ic-prepend-from Target selection: ic-target, ic-replace-target DOM manipulation: ic-add-class, ic-remove-class, ic-remove-after 8 / 21
  • 27. Intercooler features HTTP verbs: ic-get-from, ic-post-to ic-delete-from, ic-patch-to, ic-put-to Variants: ic-append-from, ic-prepend-from Target selection: ic-target, ic-replace-target DOM manipulation: ic-add-class, ic-remove-class, ic-remove-after Dependencies: ic-deps, ic-src, implied dependencies 8 / 21
  • 28. Intercooler features HTTP verbs: ic-get-from, ic-post-to ic-delete-from, ic-patch-to, ic-put-to Variants: ic-append-from, ic-prepend-from Target selection: ic-target, ic-replace-target DOM manipulation: ic-add-class, ic-remove-class, ic-remove-after Dependencies: ic-deps, ic-src, implied dependencies And more! 8 / 21
  • 29. Triggering Intercooler requests Intercooler uses the "natural" event for an element to trigger a request: For form elements, issue the request on the submit event. For input elements except buttons, issue the request on the change event. For all other elements, including buttons, issue the request on the click event. 9 / 21
  • 30. Triggering Intercooler requests Intercooler uses the "natural" event for an element to trigger a request: For form elements, issue the request on the submit event. For input elements except buttons, issue the request on the change event. For all other elements, including buttons, issue the request on the click event. Other triggers can be specified using ic-trigger-from or ic-trigger-on. 9 / 21
  • 31. Example: form eld validation Validate an email address when it changes 10 / 21
  • 32. Example: form eld validation Invalid email address 11 / 21
  • 33. Example: form eld validation Email address already used 12 / 21
  • 34. Example: form eld validation Success! 13 / 21
  • 35. Example: form eld validation template: inlinevalidation.html <form> {% csrf_token %} {% include 'examples/email_address_form_group.html' %} <button class="btn btn-default">Submit</button> </form> 14 / 21
  • 36. Example: form eld validation template: email_address_form_group.html <div class="form-group {{ form_group_class }}"> <label class="control-label"> Email Address </label> <input class="form-control" name="email" ic-post-to="{% url 'contact-email' %}" ic-target="closest div" ic-replace-target="true" value="{{ email }}" > {% if error_message %} <span class="help-block text-error">{{ error_message }}</span> {% endif %} </div> 15 / 21
  • 37. Example: form eld validation view: from django.core.validators import validate_email, ValidationError def contact_email_view(request): email = request.POST['email'] context = {'email': email} try: validate_email(email) except ValidationError: context['error_message'] = "Please enter a valid email address" else: if email != "test@test.com": context['error_message'] = "That email is already taken. Please enter another email." else: context['form_group_class'] = "has-success" if 'error_message' in context: context['form_group_class'] = "has-error" return render(request, 'examples/email_address_form_group.html', context=context) 16 / 21
  • 39. Philosophy It can be easy for some developers to dismiss intercooler as overly simple and an archaic way of building web applications. This is intellectually lazy. Intercooler is a tool for returning to the original network architecture of the web. Using HTML as the data transport in communication with a server is what enables HATEOAS, the core distinguishing feature of that network architecture. Intercooler goes with the grain of the web, rather than forcing a more traditional thick-client model onto it, thereby avoiding the complexity and security issues that come along with that model. Yes, intercooler is simple, but it is a deceptive simplicity, very much like the early web. http://intercoolerjs.org/docs.html#philosophy 18 / 21
  • 40. On Churn Many javascript projects are updated at a dizzying pace. Intercooler is not. This is not because it is dead, but rather because it is (mostly) right: the basic idea is right, and the implementation at least right enough. This means there will not be constant activity and churn on the project, but rather a stewardship relationship: the main goal now is to not screw it up. The documentation will be improved, tests will be added, small new delarative features will be added around the edges, but there will be no massive rewrite or constant updating. This is in contrast with the software industry in general and the front end world in particular, which has comical levels of churn. Intercooler is a sturdy, reliable tool for web development. http://intercoolerjs.org/docs.html#philosophy 19 / 21
  • 41. Finally… Your magical pony looks more magical. 20 / 21
  • 42. Finally… Your magical pony looks more magical. 20 / 21