Events - When to call them twice
Hello Everybody,
I continue to read "jQuery In Action" and one doubt came into my mind when I was reviewing the chapter 4 that talks about Event handlers.
Within a particular code sample (bamboo.html), the author has written a ".change(fn...)" method with a function to handle the event that manipulates the changes made within an "input[type=text]" to reflex the price to pay against the amount of product the client selects , and, at the end of the same wrapped set, it's included a call to the "change()" method again (see the code below).
My question is, when is it necessary to call the event handler (e.g. ".change()") more then one time within the same wrapped set?
Note: The book's author tries to explain why, but it has been hard to understand.
- $('span[price] input[type=text]').change(function(){
- $('~ span:first',this).text( $(this).val() * $(this).parents("span[price]:first").attr('price') ); }).change();
Thanks in advance.
Luciano Daher.