-
Notifications
You must be signed in to change notification settings - Fork 106
Ajax Thought
Caffeine Lab edited this page May 24, 2017
·
5 revisions
I didn't see a way to load live content into the lightbox without using an iFrame so I cobbled something together. Maybe this helps someone, maybe there's a better way..... of which there is at the bottom of this entry.
The link
<a href="#the_content" data-url="link-to-source" data-rel="lightcase">Some Link</a>
The div
<div id="the_content" style="display:none;"></div>
The script
jQuery(document).ready(function ($) {
$('a[data-rel^=lightcase]').lightcase({
onInit: {
rewrite: function() {
$.ajax({
url: $(this).attr("data-url") + '?_=' + new Date().getTime(),
type: 'GET',
success: function(data) {
$('#the_content').html(data);
}
});
}
}
});
});
The Better Way
<a id="myElement" href="link-to-source">Simple AJAX Load</a>
$("#myElement").lightcase({
type: "ajax",
ajax: {
type : "get",
dataType : "html"
}
});