JSFiddle - React, Tailwind, and code Playground
HTML
<p id="text">This will Change with the Button Click.</p>
<input type="button" data-action="myApp:specialName:changeText" value="Click" />
CSS
body{
padding:20px;
}
JavaScript
$('[data-action]').live('click', function(e) {
e.preventDefault();
route($(this).data('action'), this);
});
function route(input, object) {
var complex = true;
var refine = null;
var route = input.split(':');
if (route[1] == undefined) {
complex = false;
}
if (complex) {
var call = '';
for (var func in route) {
call += route[func] + '.';
}
//refine = eval(call.substring(0, call.length - 1));
refine = ( new Function( call.substring(0, call.length - 1) ) )();
refine(object);
return;
}
}
var myApp = {
specialName: {
changeText: function(item){
console.log(item);
$('#text').text('Changed Successfully');
}
}
}