Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for all types of elements (not just inputs) #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ntziolis
Copy link

@ntziolis ntziolis commented Jan 4, 2011

Hi,

since i needed it for one of my projects I extended the current functionality to also be able to handle non input fields (read only that is).

Its a minor change in the 'setValue' method. Basically instead of using the given field it now analyzes the target by getting the tag name of the target. Based on this tag name the field is determined within the newly created 'getField' method.

The addition is made in a way that it should not break any existing code. It might be necessary to add additional tags to the switch statement in the 'getField' method though. Right now it will default back to using 'html' as field if the tag was not a recognized one.

…input fields)

Retrieving the field to update based on the nodeName (tag name)
@Dhodaalaa
Copy link

I understand this is over a year old, but in case somebody is still monitoring this thread: In the setValue() function, in the else clause, shouldn't you do target[field] = value instead of $(target).data(field, value)? My understanding is that if you landed into the else clause you already know that the target of the change is a Javascript object and not a DOM element, so $(target) doesn't give you any benefit other than to make an array out of the target object. Also .data simply adds a .data field to the object and stores the field/value pair there instead of overwriting the value of the existing field in the target object.

Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants