Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home JavaScript
 

Event Handler and Actions

 

An effective JavaScript and Ajax based application is based on the ability of the developer to properly handle even handler and the corresponding actions. Although it’s only one part of the application, developers have to make sure that these functions is properly coded or else they will end up with a buggy application or even worst. If they are able to properly code event handlers, the options on how the application will work on the client side are almost endless. It’s practically a make or break function in order to build a powerful Ajax based application.


What makes event handlers remarkable is the ability to launch more than one action. The usual concept about event handler is that it can only launch a single action. A single action setting is highly recommended for most developers since it will be very easy to configure. By simplifying the action, they will be able to launch an effective application.


But a single action from an event handler might not be enough in some scenarios. There are applications that require more than one action so that it could provide more data for the users. In this case, developers could still exploit the functions of event handler further.


Single Action from an Event Handler

The basic setting of an event handler only has one action. In using one action, developers will only enable one function after a certain action has been implemented from the user side. For example, a user clicks on a button and the user will immediately be provided with a response depending on the preference of the developer.


In this case, the developer would only have to provide three parameters in event handlers – the input, value and its corresponding action. The input and value could be a link, button or anything the developer prefers. What’s important is the attached action noticeable to the users.


More than One Action from an Event Handler

If the developer wants to be aggressive in the actions from the event handler, they should expand the actions that come from the event handler. What’s surprising about this feature in JavaScript is in its simplicity. Developers have often disregarded this feature but if they are willing to use it, they can easily implement it.


Implementing more than one action in an event handler is very simple. It will still have the same parameters but will have more than one corresponding action separated by a semi-colon.


Sequencing Functions

Implementing more than one function doesn’t mean that all actions will happen at the same time. The functions will be implemented one at a time and will only be launched after the function has been completed. The semicolon will suggest the sequence of events the function will consider.


This is a very important consideration for developers. They need to launch the lightweight function first before launching the heavy functions. By doing so, they will ensure that the application will be as lightweight as possible without jeopardizing the general setting of their Ajax or JavaScript based application.



Read Next: Limiting JavaScript Access to Other Websites



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links