Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Turbolinks 入門
Search
蒼時弦や
December 02, 2016
Programming
2
380
Turbolinks 入門
Ruby Conf Taiwan 2016 簡報
蒼時弦や
December 02, 2016
Tweet
Share
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
170
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
180
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
430
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
650
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
390
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
460
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
480
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
260
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
290
Other Decks in Programming
See All in Programming
Introducing RemoteCompose: break your UI out of the app sandbox.
camaelon
2
130
コードとあなたと私の距離 / The Distance Between Code, You, and I
hiro_y
0
210
Temporal Knowledge Graphで作る! 時間変化するナレッジを扱うAI Agentの世界
po3rin
5
1k
React Nativeならぬ"Vue Native"が実現するかも?_新世代マルチプラットフォーム開発フレームワークのLynxとLynxのVue.js対応を追ってみよう_Vue Lynx
yut0naga1_fa
2
1.9k
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
120
Amazon Verified Permissions実践入門 〜Cedar活用とAppSync導入事例/Practical Introduction to Amazon Verified Permissions
fossamagna
2
100
AIと人間の共創開発!OSSで試行錯誤した開発スタイル
mae616
2
830
CSC305 Lecture 11
javiergs
PRO
0
310
Vueのバリデーション、結局どれを選べばいい? ― 自作バリデーションの限界と、脱却までの道のり ― / Which Vue Validation Library Should We Really Use? The Limits of Self-Made Validation and How I Finally Moved On
neginasu
2
1.7k
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
18
9.1k
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1.3k
ボトムアップの生成AI活用を推進する社内AIエージェント開発
aku11i
0
1k
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
272
21k
Documentation Writing (for coders)
carmenintech
75
5.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.7k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
BBQ
matthewcrist
89
9.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.7k
Balancing Empowerment & Direction
lara
5
710
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
10
900
Thoughts on Productivity
jonyablonski
71
4.9k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
How to Ace a Technical Interview
jacobian
280
24k
Transcript
Turbolinks 入門
WEB GENERATOR GAME DEVELOPER 襟 儘 䓛⛳ @elct9620
None
技術原理 Turbolinks API 效果展示 Turbolinks 入門
Turbolinks 是基於 HTML5 的 History API 所實現 的技術。 技術原理
在過去 History API 只用於切換上一頁或者下一頁。 技術原理
Turbolinks API history.back(); history.forward(); 原始的 History API
HTML5 新增的 pushState 功能則讓我們可以對瀏 覽紀錄進行操作。 技術原理
技術原理
技術原理
技術原理
技術原理
技術原理 var newState = { pageName: 'New Page', controller: 'acticle',
id: '1' }; window.history.push( newState, newState.pageName, "/article/1");
技術原理
技術原理
另外還有 popState 跟 history.state 可以讓我們存 取和捕捉目前的狀態。 技術原理
Turbolinks 是受到 PJAX 技術的影響產生的產物。 技術原理
技術原理
技術原理
很多時候我們在使用 Rails 會把 Turbolinks 關閉, 因為跟 JavaScript 常常出現衝突。 不過這只是因為沒有了解 Turbolinks
的使用方式而 已。 Turbolinks API
Turbolinks API <a href="https://google.com" data-turbolinks=“false"> Google </a> 取消 Turbolinks 效果
Turbolinks API <script data-turbolinks-eval=“false" src="// cdn.example.js/pixel.js"></script> 限制 JavaScript 重複執行
Turbolinks API <link href="/assets/style-201611041620.css" data- turbolinks-track="reload" rel="stylesheet"/> 追蹤 Assets 更新並且重新載入
Turbolinks API <meta name="turbolinks-root" content="/app"> 限定 Turbolinks 生效範圍
Turbolinks API <meta name="turbolinks-cache-control" content="no- cache"> 取消頁面快取
Turbolinks API <div id="shared" data-turbolinks-permanent>1 items</ div> 跨頁面共享元素
Turbolinks API .turbolinks-progress-bar { height: 5px; background-color: green; } 顯示進度條
雖然透過屬性的設定可以做到不少調整,但是與 JavaScript 搭配的時候,還是需要能夠相互搭配才 行。 Turbolinks API
Turbolinks API $(document).ready(function() { // OnLoad... }); 大多數時候我們會在 jQuery 的
ready() 做處理
Turbolinks API $(document).on("turbolinks:load, function(){ // OnLoad... }); 不過在 Turbolinks 要改用
Turbolinks 的 load 事件
jQuery.ready => 頁面讀取觸發 Turbolinks:load => 替換頁面時觸發 Turbolinks API
jQuery.ready => 頁面讀取觸發 Turbolinks:load => 替換頁面時觸發 Turbolinks API
jQuery.ready => 頁面讀取觸發 Turbolinks:load => 替換頁面時觸發 Turbolinks API
Turbolinks API Turbolinks.visit('/edit/1'); 觸發 Turbolinks 換頁
Turbolinks API Turbolinks.visit('/edit/1', {action: 'replace'}); 用 replaceState 方式換頁
Turbolinks API Turbolinks.clearCache(); 清除快取
Pinterest 效果 DEMO 時間
None