Skip to content

jQuery 1.5 breaks support for fields with '.' in name #21

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

Open
ntziolis opened this issue Feb 1, 2011 · 2 comments
Open

jQuery 1.5 breaks support for fields with '.' in name #21

ntziolis opened this issue Feb 1, 2011 · 2 comments

Comments

@ntziolis
Copy link

ntziolis commented Feb 1, 2011

The current version is not able to link from object to form fields, when using a '.' in a field name as ASP.NET MVC does by default when having hierarchical data in a form (when using the EditorFor<> helpers for model properties).

$(data).setField("Name", "SomeNewValue"); <- works (in first level of hierarchy, so no '.'
$(data).setField("English_Name", "SomeNewValue"); <- works (uses the id)
$(data).setField("English.Name", "SomeNewValue"); <-does not work (should use the name)

Thats the commit:
f2b13ff

@D1g1talEntr0py
Copy link

I have also noticed this behavior. I am using Spring MVC and also need to have the model mapped using dot notation. I have been trying to figure out a fix for this but have been unsuccessful as of yet. Leaning toward implementing my own solution.

@D1g1talEntr0py
Copy link

I was able to modify the setField function to fix this behavior. The block of code that handles updating the backing object would split the name on a '.' character. I think it has something to do with name-spacing for the event handler. If the code is modified to remove this, it works perfectly fine. This will, of course, break the initial design, but I for one will never need to code to behave how it was originally designed. Here is the code;

This

var parts = field.split('.');
parts[1] = parts[1] ? '.' + parts[1] : '';
    
var $this = $(target),
args = [ parts[0], value ];
    
$this.triggerHandler(eventNameSetField + parts[1] + '!', args);
if (value !== undefined) {
    target[ field ] = value;
}
$this.triggerHandler(eventNameChangeField + parts[1] + '!', args);

becomes this...

var $this = $(target),
args = [field, value];

$this.triggerHandler(eventNameSetField + '!', args);
if (value !== undefined) {
    target[field] = value;
}
$this.triggerHandler(eventNameChangeField + '!', args);

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

No branches or pull requests

2 participants