diamond-ext-jsapi ~master

Diamond extension for a js/jquery api.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

jsapi

Dub version Dub downloads License

Jsapi is an extension to views in Diamond, which extends views with an easy-to-use integration of js/jquery.

extensions.config

ViewExtension|jsapi|diamond.extensions.jsapi

API Docs

void ajax(HTTPMethod method, string name, string url, string prepareFunction, string callbackFunction)

Requires: http://jquery.com/

This function will generate a javascript function that executes an ajax call through jquery.

Example:

<a href="#" onclick="authenticate()">Authenticate</a>

@:ajax(HTTPMethod.POST, "authenticate", "/login", "prepareAuth", "authenticated");

<script type="text/javascript">
function prepareAuth() {
    var authArgs = {
        data: {
           username: 'test',
           password: '1234'
        },
        dataType: 'json'
    };
    
    return authArgs;
}

function authenticated(result) {
    if (result.success) {
        console.info(result);
    } else {
        console.error("An error happened during the request.");
    }
}
</script>

Note: You don't need to specify dataType if the dataType is json. The example above only has it for demonstration.

Authors:
  • Jacob Jensen
Dependencies:
none
Versions:
0.0.3 2017-Oct-20
0.0.2 2017-Oct-20
0.0.1 2017-Oct-20
~master 2017-Oct-20
~0.0.3 2017-Oct-20
Show all 7 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 23 downloads total

Score:
0.7
Short URL:
diamond-ext-jsapi.dub.pm