Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh a data-refresh-url item #57

Open
Gelurban opened this issue Sep 24, 2013 · 2 comments
Open

Refresh a data-refresh-url item #57

Gelurban opened this issue Sep 24, 2013 · 2 comments

Comments

@Gelurban
Copy link

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!

@lonnieezell
Copy link

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.

@oppianmatt
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants