-
Notifications
You must be signed in to change notification settings - Fork 13
Simple Bookmarklets
jagthedrummer edited this page Nov 13, 2012
·
1 revision
Run something like this:
rails generate easymarklet:simple foobaz
This wil add a file to your javascripts directory that will hold the code for your bookmarklet.
app/assets/javascripts/foobaz_bookmarklet.js
(function(){
// Your bookmarklet code goes here
})();
You might alter it to look something like this:
(function(){
var p = document.createElement('p');
p.appendChild(document.createTextNode('Foo vs. Baz'));
document.body.appendChild(p);
})();
Then in a view template you can link to your bookmarklet using the easymarklet_js helper.
<%= link_to "Foo Baz!", easymarklet_js('foobaz_bookmarklet.js') %>
The resulting link will contain a small snippet of javascript that will load your bookmarklet code into the current page and execute it. Place some instructions for your users near the link that tells them to drag the link into their bookmark bar.