Last active
August 29, 2015 14:07
-
-
Save jaggy/f94c54cf29aaa6d29127 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#" data-model="Table" data-action="add_row" data-param="">Add row</a> | |
<a href="#" data-model="Table" data-action="delete_row" data-param='{"id": 1}'>Add row</a> | |
<script> | |
var Table = { | |
add_row: function (self, params) { | |
console.error('adding_row'); | |
}, | |
delete_row: function (self, params) { | |
console.error('deleting_row'); | |
var element = $(self); | |
var id = params.id; | |
} | |
}; | |
$(document).on('click', '[data-trigger="click"]', function (event) { | |
event.preventDefault(); | |
var $elem = $(this); | |
var model = $elem.attr('data-model'); | |
var action = $elem.attr('data-action'); | |
var params = $elem.attr('data-params'); | |
if (params != '') { | |
params = JSON.parse(params); | |
} | |
window[model][action](this, params); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment