data-highlight-color

Change the color (by defaut, blue) of highlighted elements.

Available events: data-highlight-color-before, data-highlight-color-complete, data-highlight-color-success, data-highlight-color-failure, data-highlight-color-empty, data-highlight-color-not-empty

Default color for highlighting is blue. But you can change this default color using data-highlight-color. You can also define a color according to an event: this is common to see text highlighting green when an ajax call has been proceeded; and red if an error occured. Distinguish highlights according to events is possible using data-highlight-color-(event).

data-highlight-color should be used with data-highlight option.
If data-highlight-color is used without event, it will be the default color for highlighting (instead of blue).
data-highlight content will be used as selector for each data-highlight-color-* that do not have their corresponding data-highlight-color-* defined. See "Particular cases" example.

Usage


  • data-highlight="(selector to highlight)"
  • data-highlight-color="(color to use for highlighting)"

Example


  • data-highlight="#save"
  • data-highlight-color="yellow"
  • data-highlight-color-success="green"
  • data-highlight-color-failure="red"

Live examples

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-color-succerror-handler.php"
            data-input="#inputs"
            data-highlight="#hello"
            data-highlight-color-success="green"
            data-highlight-color-failure="red"
            />

    <br/><br/>

    <div id="hello">This text will be highlighted according to the ajax call status</div>

</div>

This form looks like this:


<input
        type="button"
        value="Click me: highlight will not be blue!"
        class="btn domajax click"
        data-endpoint="highlight-color-default-handler.php"
        data-highlight=""
        data-highlight-color="#D0A9F5"
        />

This form looks like this:


<input
        type="button"
        value="Success and Failures"
        class="btn domajax click"
        data-endpoint="highlight-color-all-in-a-row-handler.php?type=codes"
        data-highlight=""
        data-highlight-color-before="#FFFF00"
        data-highlight-color-success="#00FF00"
        data-highlight-color-failure="#FF0000"
        />

<br/>

<input
        type="button"
        value="Empty and Not empty"
        class="btn domajax click"
        data-endpoint="highlight-color-all-in-a-row-handler.php?type=content"
        data-highlight=""
        data-highlight-color-before="#00FFFF"
        data-highlight-color-empty="#FF00FF"
        data-highlight-color-not-empty="#FFFFFF"
        />

This form looks like this:


<p>
    If <em>data-highlight</em> is used alone without <em>data-highlight-color</em>, <em>data-highlight-color</em> is
    set to blue.
</p>

<input
        type="button"
        value="This button will highlight in blue.."
        class="btn domajax click"
        data-endpoint="highlight-color-particular-cases-handler.php?test=blue"
        data-output=""
        data-highlight=""
        />

<br/><br/>

<p>
    If <em>data-highlight-color</em> is used alone without <em>data-highlight</em>, <em>data-highlight</em> is
    set to an empty string ( "" ) so the current domajax element will be highlighted.
</p>

<input
        type="button"
        value="There are no data-highlight, so..."
        class="btn domajax click"
        data-endpoint="highlight-color-particular-cases-handler.php?test=nohighlight"
        data-output=""
        data-highlight-color="red"
        />

<br/><br/>

<p>
    When you are using <em>data-highlight</em> alone, it is an alias for <em>data-highlight-success</em>. But, if you
    are using
    <em>data-highlight</em> and some <em>data-highlight-color-(event)</em> options, then <em>data-highlight</em> will
    apply for the <em>(event)s</em> specified, and no more for <em>success</em> event if <em>data-highlight-color-success</em>
    is
    not defined.
</p>

<input
        type="button"
        value="This button will highlight if response is empty..."
        class="btn domajax click"
        data-endpoint="highlight-color-particular-cases-handler.php?test=nonempty"
        data-output=""
        data-highlight=""
        data-highlight-color-empty="#00FF00"
        />

<br/><br/>

<p>
    If <em>data-highlight-color-complete</em> and <em>data-highlight-color-success</em> (or <em>failure</em>) are
    defined,
    if the ajax call succeed, the <em>data-highlight-color-complete</em> color will be used. In fact, both highlights
    will be made but as
    jQuery executes <em>complete</em> callback just after <em>success</em>, there will be no time to see the
    <em>success</em>
    color.
</p>

<input
        type="button"
        value="Complete is red, Success is green..."
        class="btn domajax click"
        data-endpoint="highlight-color-particular-cases-handler.php"
        data-highlight=""
        data-highlight-color-complete="red"
        data-highlight-color-success="green"
        />


See also    data-highlight   data-callback   data-script 

Table of contents

All the documentation at a glance

Domajax options

And more with domajax