Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Turbolinks 入門
Search
蒼時弦や
December 02, 2016
Programming
410
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Turbolinks 入門
Ruby Conf Taiwan 2016 簡報
蒼時弦や
December 02, 2016
More Decks by 蒼時弦や
See All by 蒼時弦や
2024 - COSCUP - Clean Architecture in Rails
elct9620
2
230
2023 - RubyConfTW - Rethink Rails Architecture
elct9620
0
290
20230916 - DDDTW - 導入 Domain-Driven Design 的最佳時機
elct9620
0
520
2023 - WebConf - 選擇適合你的技能組合
elct9620
0
750
20230322 - Generative AI 小聚 ft. Happy Designer
elct9620
0
500
2022 - 默默會 - 重新學習 MVC 的 Model
elct9620
1
530
MOPCON 2022 - 從 Domain-Driven Design 看網站開發框架隱藏
elct9620
1
550
2022 - COSCUP - 我想慢慢寫程式該怎麼辦?
elct9620
0
330
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
360
Other Decks in Programming
See All in Programming
AI活用は、個人から組織へ|マルチプレイヤーエージェントハーネス「QM」の社内活用事例 / AI use is moving from individuals to orgs
rkaga
1
270
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
690
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
310
AHC070解法紹介
eijirou
0
140
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
380
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
150
Heart of Swift Concurrency
koher
0
1k
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.2k
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
260
Security issues being discussed on Web Platforms
petamoriken
0
1.3k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
570
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
130
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
52k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
ラッコキーワード サービス紹介資料
rakko
1
5M
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
sira's awesome portfolio website redesign presentation
elsirapls
0
420
Docker and Python
trallard
47
4.2k
Skip the Path - Find Your Career Trail
mkilby
1
240
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