Link To
A simple util to make any element linkable using a data attribute.
Useful for cases where the element can't be wrapped with an anchor tag.
Basic Usage
This util will self instantiate and automatically be set up for elements with a
data-link-to
attribute on them.
<div data-link-to="/foo"></div>
require([ "lib/components/link_to" ], function(LinkTo) {
// No need to do anything.
});
Providing a context
For situations where content is loaded via AJAX (for example), the
LinkTo
constructor receives a
context
argument so you can specify the new context for this.
<div class="js-lightbox">
<div data-link-to="/foo"></div>
</div>
new LinkTo(".js-lightbox");