Open Gelurban opened 11 years ago
This is exactly what I'm trying to do, also. Did you ever get this working?
I would love to have a static html page (or a cached page on the server) being sent to the client that only refreshes one or two dynamic portions. This would work great when a lot of content is static, but you wan to have different links if user is signed in, and have the page automatically refresh items on page load.
Couldn't you do something like?
< div id="my-div" data-refresh-url="info">
< a class="refresh-btn" data-refresh="#my-div" > Refresh! < /a>
<script>
$(document).on('click', '.refresh-btn', function() {
$('#my-div').trigger('eldarion-ajax:success');
});
</script>
It's saying when you click the btn, trigger the success event (which has the refresh handler attached).
See in eldarion-ajax-handlers.js file:
$(document).on('eldarion-ajax:success', '[data-refresh]', Handlers.prototype.refresh);
Handlers.prototype.refresh = function(e, $el) {
$.each($($el.data('refresh')), function(index, value) {
$.getJSON($(value).data('refresh-url'), function(data) {
$(value).replaceWith(data.html);
});
});
};
You can put that in a separate js file. Infact I have another js full of our eldarion custom plugins.
Hello,
I'd like to know how could I refresh the following div by clicking on a button or anchor. I tried the following code:
< div id="my-div" data-refresh-url="info">
< a data-refresh="#my-div" > Refresh! < /a>
Is it possible to request an item refresh without sending a Get request to the page?
Thanks in advance!