Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
jQuery: Can't interact with new HTML
Old 07-15-2009, 08:08 AM jQuery: Can't interact with new HTML
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Hi everyone,

I've got the following code;

Code:
 $("td.printer").click(function() {
   var printerId = $(this).attr('id');
   var printerName = $(this).html();
 
   // If there isn't already an input box open... make one
   if (printerName.search(/input name=\"/) != 1) {
     $(this).html('<input name="printer[' + printerId + ']" value="' + printerName + '" class="printer_name" />');
   }
 });
Which creates an input box on click with the printer name in it (for editing). However, the following code doesn't work...?

Code:
 // When user unclicks the box
 $("input.printer_name").blur(function() {
 
   alert("poooo");
 
 });
I know that if it's an AJAX request then you would put the additional code in a callback function. What do I do in this circumstance?

Thanks in advance
__________________

Please login or register to view this content. Registration is FREE
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
 
Register now for full access!
Old 07-15-2009, 10:06 AM Re: jQuery: Can't interact with new HTML
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Place the event inside of the IF which creates the INPUT element:
Code:
 $("td.printer").click(function() {
   var printerId = $(this).attr('id');
   var printerName = $(this).html();
 
   // If there isn't already an input box open... make one
   if (printerName.search(/input name=\"/) != 1) {
     $(this).html('<input name="printer[' + printerId + ']" value="' + printerName + '" class="printer_name" />');
      // When user unclicks the box
     $("input.printer_name").blur(function() {
     
       alert("poooo");
     
     });
   }
 });
The blur() event fires when an element loses focus. Is that your intent here?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-15-2009, 10:44 AM Re: jQuery: Can't interact with new HTML
EdB
Skilled Talker

Posts: 79
Name: Ed Barnett
Trades: 0
Ahh wayfarer you are a legend (again)! Thank you.

Yes, my intention is that once a user clicks out of the input box is disappears again and the changes are updated using ajax
__________________

Please login or register to view this content. Registration is FREE
EdB is offline
Reply With Quote
View Public Profile Visit EdB's homepage!
 
Reply     « Reply to jQuery: Can't interact with new HTML
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34203 seconds with 12 queries