I'm an intermediate JS programmer and it's a world of difference from PHP (esp. when I'm not an OOP programmer even in PHP).
I am interested in defining my own events in jQuery as a possible simplification of my programming, and I'll use a simple example:
often you have rows of records in a table. user wants to make a row inactive. System is set so that when this happens the row fades out and disappears. Let's suppose there could be 3 ways to do this:
- hit an inactive icon
- with the row highlighted hit i or
- right click and select inactive from a context menu.
what I'd like to do is something like:
$('.datarow').on('rowinactive',function(){ /* etc */ });
any of the three actions above would set $('#row12345')
as .inactive
, and the event handler would take it from there. I see it as you have somewhat of a separation between the state and the action(s) related to the state.
I hope this is a simple example to start. Can anyone offer some example code for this?