data-highlight

Highlights a selector to a given color (blue by default) when events occurs.

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

This is common to see text highlighting when there are no save button on a form, this text highlighting graphically tells the user that a change has been taken into account. Put a selector inside data-highlight to highlight it when the event occurs.
If you want to highlight different selectors according to events, you can use data-highlight-(event), and they will be used if this event occurs.

data-highlight requires jquery-ui included, as .animate() method needs jquery ui to process colors.
data-highlight used alone (without data-highlight-color) is an alias for data-highlight-success.
If data-highlight is empty, element containing the domajax call will be used as highlighted selector.

Usage


  • data-highlight="(selector to highlight)"

Example


  • data-highlight="#save"

Live examples

This form looks like this:


<input
        type="button"
        value="Click me"
        class="btn domajax click"
        data-lock=""
        data-endpoint="highlight-basics-handler.php"
        data-highlight=""
        />

<br/><br/>

<input
        id="hello"
        type="text"
        placeholder="Edit me"
        class="btn domajax keyup"
        data-endpoint="highlight-basics-handler.php"
        data-lock=""
        data-highlight="#hello"
        data-highlight-color="red"
        />

This form looks like this:


<div id="input">

    <label for="fruit">Enter a fruit</label>
    <input
            type="text"
            id="fruit"
            class="btn domajax keyup"
            data-endpoint="highlight-saving-handler.php"
            data-input="#input"
            data-output="#output"
            data-highlight=""
            />

    <br/><br/>

    <label for="vegetable">Enter a vegetable</label>
    <input
            type="text"
            id="vegetable"
            class="btn domajax keyup"
            data-endpoint="highlight-saving-handler.php"
            data-input="#input"
            data-output="#output"
            data-highlight=""
            />

</div>

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

This form looks like this:


<div id="inputs">

    Do you want the server to send a 500 error (so the ajax call will fail)?

    <br/><br/>

    <input type="radio" name="want_error" value="yes"/> Yes
    &nbsp;&nbsp;
    <input type="radio" name="want_error" value="no" checked/> No

    <br/><br/>

    <input
            type="button"
            value="Go"
            class="btn domajax click"
            data-endpoint="highlight-succerror-handler.php"
            data-input="#inputs"
            data-highlight-success="#success"
            data-highlight-failure="#failure"
            />

    <br/><br/>

    <div id="success">This text will be highlighted if the ajax call succeed</div>
    <div id="failure">This text will be highlighted if the ajax call fails</div>

</div>


See also    data-highlight-color   data-callback   data-script 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax