CSS-Tricks / MovingBoxes

Simple horizontal slider which grows up the current box when it's in focus (image, title & text) and back down when it's not in focus.
http://css-tricks.github.io/MovingBoxes/
GNU Lesser General Public License v3.0
280 stars 147 forks source link

Form field name attributes #61

Closed andrewjknox closed 12 years ago

andrewjknox commented 12 years ago

Hi there, Minor feature request really, I've added it into my own copy of your slider as I needed it and thought it might help someone else.

I've got an ASP.NET AJAX form in one of the panels that sit within a slider that's configured to infinity scroll.

That means it'll clone my form and therefore have two sets of forms fields with the same "name" attribute and therefore the values can come across as being empty and fail with validation when it all gets sent to the server ready for processing into a CMS.

What I did was, was to replicate what you do when you remove the "id" attributes from cloned elements, and do the same thing for the "name" attributes.

Cheers, Andrew

Mottie commented 12 years ago

I'm not sure if you had any problems or not, but the plugin does automatically remove all id's and disable all form elements inside of the clone panels... see line 136-137

andrewjknox commented 12 years ago

Line 137 was the line I copied actually to remove name attributes.

Even though the clone form had everything disabled, on the server side, it was trying to read form fields with the same name, because two names were being posted. So one would have it's value empty, one would be populated, but because it was validating effectively the same form twice, once with valid data, and again with empty data, it failed.

It's kind of an edge case tbh, and probably only for peeps using ASP.NET for their website :)

Mottie commented 12 years ago

So what did you do to fix it? I think I'll just include it as a just-in-case... something like this?

$(this).find('a,input,textarea,select,button,area').removeAttr('name').attr('disabled', 'disabled');
andrewjknox commented 12 years ago

Aye, that's all I did, just remove the name attributes via .removeAttr('name')

Mottie commented 12 years ago

Ok, I've just updated the plugin to v2.2.5 with the change above. Thanks again!