data-value

Process the ajax request only if selector's inputs have been updated.


Sometimes, we need to process an ajax call as soon as users are typing, such as on a search form, or when a field is auto-completed / auto-saved. But, there are some keys that do not change field's contents, such as arrows or ctrl / alt keys. This option let you avoid sending an ajax call twice if a value has not been updated.

This is recommanded to include the JSON2.js library if you are using data-value for better compatibility.
If data-value is set but empty, the domajax element will be used as selector.
By default, data-value is set to the domajax keyup event.

Usage


  • data-value="(selector that should change)"

Example


  • data-value="#input"

Live examples

This form looks like this:


<label>Type something:</label>
<input
        type="text"
        class="domajax keyup"
        data-endpoint="value-typing-handler.php"
        data-input=""
        data-output="#output"
        />

<br/><br/>

<div id="output"></div>

This form looks like this:


<div id="inputs">

    <label>Enter a fruit</label>
    <input type="text" id="fruit" value="orange"/>

    <br/>

    <input
            type="button"
            value="Submit"
            class="btn domajax click"
            data-endpoint="value-other-handler.php"
            data-input="#inputs"
            data-output="#output"
            data-value="#fruit"
            />

</div>

<div id="output"></div>

This form looks like this:


<div id="inputs">

    <label>Enter a fruit</label>
    <input type="text" id="fruit"/>

    <br/>

    <label>Enter a vegetable</label>
    <input type="text" id="vegetable"/>

    <br/>

    <input
            type="button"
            value="Submit"
            class="btn domajax click"
            data-endpoint="value-form-handler.php"
            data-input="#inputs"
            data-output="#output"
            data-value="#inputs"
            />

</div>

<div id="output"></div>


See also    data-delay   data-input   data-input-attr 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax