Saturday, 10 August 2013

Jquery element not recognized, no action to call ON to make it live

Jquery element not recognized, no action to call ON to make it live

I'm still struggling with the very basics of making new items "Live". I
understand how to get them noticed on an action, but what about a non
action element.
I need to create a preview of new items listed. I am using append.
I am checking the length of the new element and it returns true every time
(meaning id doesn't exist). Since The user will never commit an action to
the preview, how do I make it live if "On" is the correct use of live.
Step 1: user selects one of these fields from a line and calls two functions
$('.newLine').on("blur", '.item', function(){
$(".sqft, .price, .qty, .newtot").blur(function () {
sumPrice(this);
addToList(this);
});
The addToList function adds a new line item in two places, one where the
user will have to click later, so I used "on click" to make it live when I
need it.
Step 2: in the second list it creates a preview box for the group, so if
the group doesn't exist its new:
if (existPre.length === 0) {
/* append new group box */
}else{
/* append items to this group*/
}
Question: If my function appends a new box and the User user will never
click/blur/mouseover...on it.. How does Jquery know to look for it next
time when I ask for the length? It never exists.

No comments:

Post a Comment