eldarion / eldarion-ajax

a library for adding declarative ajax functionality to your website
BSD 3-Clause "New" or "Revised" License
758 stars 153 forks source link

Trigger Event on Page Load? #75

Open lonnieezell opened 9 years ago

lonnieezell commented 9 years ago

@paltman Sorry - not sure where else to ask questions and the issue that was similar to this went has gone unanswered for a while.

My javascript skills aren't the strongest. I'm more of a PHP guy.

Is it possible to trigger an event on page load? Let's say I'm serving a static HTML file, but I have a bit that I want to refresh. I would assume I could simply trigger the eldarion-ajax:success event on that element, but it doesn't seem to be working currently.

<div id="loading-bay" class="refresh-on-load" data-refresh-url="/test/baytwo" class="ajax">
    This is the loading bay.
</div>

<script>
    $(document).ready(function() {
        $('.refresh-on-load').trigger('eldarion-ajax:success');
    });
</script>

Is this correct?