Events

Code organization

Version: 1.0 - Last Modified: 02/11/2016

Developed by Wallace Rio <wallrio@gmail.com>


How use:

Inser the script on document

		<script type="text/javascript" src="events.js"></script>
	

Download

Download the script

Example 1:

Associar elemento com uma ação

Click on link below to run action

Action 1
	<script>
		events.context('example-1',{
			action1:{			
				elements:'#element1_ex1',
				callback:function(arg){
					alert('action 1');
				}
			}
		});
	</script>

Example 2:

Associar elemento com uma ação

Click on link below to run action


	<script>
		events.context('example-2',{
			action2:{			
				elements:'[name="element1_ex2"]',
				callback:function(arg){
					alert('action 1');
				}
			}
		});
	</script>

Example 3:

Associar multiplos elementos com uma ação

Click on link below to run action

Action 3
	<script>
		events.context('example-3',{
			action3:{			
				elements:'#element1_ex3, [name="element2_ex3"]',
				callback:function(arg){
					alert('action 3');
				}
			}
		});
	</script>

Example 4:

Associar elementos e evento com uma ação

Click on link below to run action

Action 4
	<script>
		events.context('example-4',{
			action4:{			
				events:'click,mouseout',
				elements:'#element1_ex4, [name="element2_ex4"]',
				callback:function(arg){
					alert('action 4');
				}
			}
		});
	</script>

Example 5:

Associar elementos HTML com uma ação.

Click on link below to run action

Action 5

	<a data-events="example-5:action5('5')">Action 5</a>

	<script>
		events.context('example-5',{
			action5:{							
				callback:function(arg){
					alert('action '+arg);
				}
			}
		});
	</script>

Example 6:

Executar ação via Javascript.

Click on link below to run action

Action 6

	

	<script>
		events.context('example-6',{
			action6:{							
				callback:function(arg){
					alert('action '+arg);
				}
			}
		});
	</script>

Using a element HTML

<a onclick="events.context('example-6').action6('6');">Action 6

OR

Execute the code:

events.context('example-6').action6('6');

API:

Attritube on TAG:

data-events="context:action:event"

context = "id_of_context"
action = "function_of_action"
events = "click,mousemove,keyup,..."