data-domajax

Process another ajax call when an event occurs.

Available events: data-domajax-before, data-domajax-complete, data-domajax-success (default), data-domajax-failure, data-domajax-empty, data-domajax-not-empty


If you're doing long-polling connections, or even if you're displaying progression information, you need to chain your ajax calls. With data-domajax-(event), you set the selector that contains the domajax configuration to process the next ajax call.

If data-domajax is set but empty, the domajax element will be used as selector.

Usage


  • data-domajax="(selector that contains the domajax call)"

Example


  • data-domajax="#progress"

Live examples

This form looks like this:


<input
        type="button"
        value="Run"
        class="btn domajax click"
        data-endpoint="domajax-progress-handler.php"
        data-domajax-not-empty=""
        data-output="#percent"
        data-delay="1000"
        data-script-empty="$('#percent').html('--'); return false;"
        />

<div>
    Progression :
    <span id="percent">--</span>
    %
</div>

This form looks like this:


<input
        type="button"
        id="step1"
        value="Run"
        class="btn domajax click"
        data-endpoint="domajax-steps-handler.php"
        data-domajax-success="#step2"
        data-output="#step1-output"
        data-replace="#step1-output"
        data-replace-by="#wait"
        data-lock=""
        />

<br/><br/>

<p>
             <span id="step1-output">
                 <i class="icon-remove"></i>
             </span>
    Step 1
</p>

<p>
             <span
                     id="step2"
                     data-endpoint="domajax-steps-handler.php"
                     data-domajax-success="#step3"
                     data-output="#step2-output"
                     data-replace="#step2-output"
                     data-replace-by="#wait"
                     data-lock="#step1"
                     ></span>
             <span id="step2-output">
                 <i class="icon-remove"></i>
             </span>
    Step 2
</p>

<p>
             <span
                     id="step3"
                     data-endpoint="domajax-steps-handler.php"
                     data-output="#step3-output"
                     data-replace="#step3-output"
                     data-replace-by="#wait"
                     data-lock="#step1"
                     ></span>
             <span id="step3-output">
                 <i class="icon-remove"></i>
             </span>
    Step 3
</p>

<div id="wait" style="display:none;">
    <i class="icon-cog"></i>
</div>


See also    data-alias   data-poll 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax