J`aime JS!! and HTML 5
The MIT License (MIT) Copyright (c) 2012 Nicolas Traeder
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- JQuery 1.7.1 http://www.jquery.com
the event that should bind to the DOM-Element
possible values: click, dblclick, load, change(inputs,select,textarea only), submit(form only)
If this parameter is set a function is called when the event is triggered which was set in "data-action"
the request URI for the AJAX request
the AJAX request type
JSONP, POST, GET
(only possible if the data-request attribute is set)
the callback function that gets called after the ajax request finished (only possible if the data-request attribute is set)
a id of a DOM-Element in which data of a request will be loaded (only possible if the data-request attribute is set)
a id of a DOM-Element which will be replaced by the data of the request. (only possible if the data-request attribute is set)
Just call the init-function of the JaimeJs - Engine at the end of your htmlpage:
$(function(){
JaimeJs.init();
});
<button id="btn-twitter" data-action="click" data-request="http://api.twitter.com/1/users/lookup.json?screen_name=cakephp&callback=?"
data-callback="twitterCallback" data-type="JSONP">ClickExample</button>
You can define custom beforeExecute and afterExecute functions which will be called before and after any triggered event.
var JaimeOptions = {
"beforeExecute" : function() {
console.log('beforeExecute');
},
"afterExecute" : function() {
console.log('afterExecute');
}
}
JaimeJs.init(JaimeOptions);
#Todo
- better example.