[jQuery] Releasing Inline Confirmation, Confirm Actions Done Right

In a web app, it is very common to have actions that destroy (delete/remove) data. These actions, if you don’t already know, should always map to POST methods. On top of that, because these actions are destructive, the UI should always ask the user for confirmation.

But how do we actually implement the confirmation dialogue though? The vanilla JavaScript confirm box would be the easiest but at the same time the ugliest - this thing stalls most web browsers until the user acts on it.

An inline popup/modal box? Perhaps, but it is still obtrusive, in the sense that the popup/model boxes are usually in the way of other tasks.

Meet Inline Confirmation - a jQuery plugin for creating easy, less obtrusive confirmation dialogues!

Feel free to give it a spin. I will add more documentation and a demo when and if I have time. ;)

[jQuery Tip] Traverse/Parse HTML String

When you are getting an HTML string from an external source (e.g. from an AJAX get result) and you want to rip out a certain part of the HTML source, you need to make sure that the ‘certain part’ is not at the top level of the HTML source.

For example, we have the following HTML string:

Hello

World

If we want to get the first paragraph element by using:

// data is the HTML source
$("p#first", data);

The above code won’t work, because the p tags are at the top level. Instead, we can simply wrap the HTML source with a div tag and that’ll do it. :)