Source

htraf-packaging / htraf / demo / examples10 / error / attr_handler.html

<!DOCTYPE html>
<html>
<head>
    <title>Errors</title>
    <script type="text/javascript">
            function onerror(info) {
                var $el = $(info.element).next();
                if(!$el.is('.error'))
                    $el = $('<div class="error"></div>')
                        .insertAfter(info.element);
                var reason = $('<pre/>').text(info.reason);
                var detail = $('<pre/>').text(info.detail);
                $el.append('<h3>Custom handler for prev. element</h3>')
                    .append(reason).append('<br>').append(detail);
            } 
    </script>
    <script type="text/javascript" src="/-/htraf/htraf.js"></script>
    <link type="text/css" rel="stylesheet" href="../../css/htraf-02.css"/> 
</head>
<body>
    <h3>Select School</h3>
    <select id="school" data-htsql="/school{code, name}"></select>
    <div>Selected School: 
        <span data-htsql="/school{na me}?code=$school"
              data-onerror="onerror(arguments[1]);"
              data-ref="school"></span>
    </div>
    <h3>Departments</h3>
    <p>Filter By Name <input id="department_name"/></p>
    <table id="department"
        data-htsql="/department{code, name, school.name}
                   ?school=$school&name~$department_name"
        data-ref="school department_name">
    </table>
    <p>
        Selected Department: 
        <em data-htsql="/department{name}?code=$department"
            data-ref="department"></em> <br/>
        Count of Courses in Selected Department: 
        <strong data-htsql="department_name.htsql"
                data-ref="department">
        </strong>
    </p>
</body>
</html>