XML Repository

jQuery: Performance Driven Html

by Sir on June 30, 2011

To the question “would not be bad on certain links within the beer-specific application user a confirmation box …”,
Of course, there are many different ways to respond and raise any technical constraint.

However, it is an opportunity to speak with a technique I love is the behavior “Driven Html.
If behind this strange name? It is simply assign behaviors to the elements of a web page through CSS selectors. Combining this with the power of jQuery to manipulate these switches,
small frames can be very generic and separate units
clearly defined elements in the HTML code.

To answer the original question in the traditional way, what are the most common approaches?

add JavaScript code in the onclick attribute in the confirmation of our link

create a generic function and a confirmation call from the onclick of the link

behavior change through a javascript link in reference to their identification.

Html behavior driven solution separates in an elegant way to display the html code of conduct.
For this, we use the fact of decorating an HTML element in one or more classes of css.
It is common practice in the css to distinguish different types of attributes.
For example, we use a normal css class for the position of an element and the use of a specific class for the shared color.
This allows separate color palette of the rest of the site and enter
and updating easier (you can also change the theme colors of a site simply without changing the rest of the CSS …).

For our problem here is that I use jQuery:

/************************************************* ***************
CSS Selectors helpers helpers
************************************************** ***************/
$ (‘. WithConfirm’). Living (‘click’, function (element) {
window.confirm return (‘Continue anyway’);

Then use the HTML code:


To return to the jQuery snippet:

Drivers of shares in jQuery, if the function returns false, stop there, if it returns true,
continues the sequence with the other actions defined. In our case there is a link
so the default is to open the link when clicked. The confirmation box to return true or false
may directly or do anything to stop or continue normally followed by the link.

I can use Live Help to manage click on existing elements, but also in future articles
could be taken to build dynamically in my page.

Because of its simple construction the labor code, as well as links to how to submit buttons.