Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 148519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:58:24+00:00 2026-05-11T08:58:24+00:00

So I’ve been working on this all day and I can’t figure out how

  • 0

So I’ve been working on this all day and I can’t figure out how to get it to work. I have a table with TD’s filled with content which is drawn from a database using a JQuery ‘getJSON’ command. I have an event handler set-up so that when you double click a TD element, its contents become a INPUT element with the default value of the enclosing TD’s previous contents.

The INPUT element is created inside a Javascript object named ‘Input’ like so:

var Input = function() {     var obj = this;     obj.docElement = $('<input/>').attr('type', 'text').val(obj.defaultValue); } 

All of this is working so far. My problem is, I want the user to be able to hit the RETURN key while the INPUT is selected to signify they’ve finished editing that field. I’ve tried something like the following:

$(obj.docElement).bind('keydown', function(e) {     if(e.which == 13) {         // do something     } } 

This works fine for the first time you edit a field; however, if you edit a field multiple times it stops working. Also if you randomly double click TD’s eventually it breaks. I tested it and determined that the INPUT element stops registering any type event, as if the ‘bind’ no longer existed on it.

I’ve done lots of googling and determined that the regular JQuery ‘bind’ handler placed on an INPUT element is unreliable. Therefore I decided to attach the event handler to the document object instead using the following:

$(document).bind('keydown', function(e) {     // do something } 

I know I can use ‘e.target’ to get the target element that the action is executed on (and this works for me, e.target correctly refers to the INPUT element).

My question is, how do I get the object that created the INPUT element in the first place? I need to be able to execute functions contained within the corresponding ‘Input’ class that was used to create the INPUT element. I need to call these functions from within the ‘$(document).bind’ function. So basically I need to be able to get an INPUT element’s parent/creator Input object.

If I haven’t explained anything clearly enough, just let me know. Any help in this matter would be greatly appreciated! I’m also open to suggestions for alternative methods (other than using ‘$(document).bind’).

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:58:24+00:00Added an answer on May 11, 2026 at 8:58 am

    I think I understand the problem …

    You can traverse the DOM to find the parent document element, but that’s not what you mean, right? You want the parent script element that has a bunch of logic that operates on the element.

    I suspect that it is probably easiest to provide some sort of reference to the parent when the input element is created … pass this to the event handler, or set it in a globally accessible location (like a current_element_parent var).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.