[jQuery] Re: Reset individual form objects to their original display state

2009-03-11 Thread Alwin Pacheco
@michaell I Haven't see your comment but you're right. In my example I show two options to get/retrieve the values of the :input fields that I use trying to set a perspective of the problem. The first one within a function and a second example directly on a specific field. Saving the whole inpu

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread mkmanning
@Alwin, it seems like all you're doing is abstracting my original suggestion of storing the original value in the data object for the corresponding input into another method that then uses the data method (e.g. the holdData function has my original suggestion as its only content). I'm not seeing f

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Alwin Pacheco
Try to use something like this... var form = function() { var self = this; this.holdData = function() { $(':input').each(function(i, field) { $(this).data('value', $(this).val()) }); return self; }; this.retrieveData = function() { $(':input').each(function(i, f

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread donb
How about just clone-ing the form node and replace the current form with the clone when you want to 'reset' it? On Mar 10, 5:31 pm, Brad wrote: > mkmanning's plugin, along with his recommendation to use jQuery's data > method instead of a global object, will work nicely. > > To answer my other

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Brad
mkmanning's plugin, along with his recommendation to use jQuery's data method instead of a global object, will work nicely. To answer my other question re: getting the full html of an element, there is this plugin: http://plugins.jquery.com/project/outerhtml. On Mar 10, 1:16 pm, Brad wrote: > I

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Brad
I'll have a look. It sounds like this is the basis for what I need. Thanks. On Mar 10, 12:58 pm, mkmanning wrote: > Haven't tried it but you could use my getAttributes plugin (http:// > plugins.jquery.com/project/getAttributes) to store the current > attributes in the data as I suggested, and th

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Brad
Thanks for pointing out about that $(this) is pointer. On Mar 10, 12:50 pm, MorningZ wrote: > Reading up on the documentation would be a good thing, as knowing the > basics, like knowing what ".html()" does, is absolutely required if > you want to learn to use this library to the fullest > > As

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Karl Rudd
Form elements have "defaultValue" and "defaultSelected" attributes. You might want to explore using those to "reset" the elements. http://www.irt.org/script/909.htm Karl Rudd On Wed, Mar 11, 2009 at 5:58 AM, mkmanning wrote: > > Haven't tried it but you could use my getAttributes plugin (http:

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread mkmanning
Haven't tried it but you could use my getAttributes plugin (http:// plugins.jquery.com/project/getAttributes) to store the current attributes in the data as I suggested, and then retrieve it later. That would get you not only the value but all other attributes. $(document).ready(function(){

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread MorningZ
Reading up on the documentation would be a good thing, as knowing the basics, like knowing what ".html()" does, is absolutely required if you want to learn to use this library to the fullest As for "If I store the value of $(this) as shown I can later retrieve the value for a specific field by

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Brad
Thanks for the help on the other question. I missed the part about reverting the value. Actually I don't think that I need to explicitly store the value. If I store the value of $(this) as shown I can later retrieve the value for a specific field by e.g., calling ... $(origFormData['age']).val(

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread mkmanning
Rather than create a global object, why not just take advantage of the jQuery data method and store the original value with its corresponding form element: $(":input").each(function(){ $(this).data('origVal',this.value) }); On Mar 10, 11:02 am, MorningZ wrote: > You forgot an important

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread MorningZ
You forgot an important part of the line origFormData[this.name] = $(this); and this is you need to store the value, so origFormData[this.name] = $(this).val(); and on your other topic, the code was also provided to revert the value back to the saved value On Mar 10, 1:36 pm, Brad wrote: >

[jQuery] Re: Reset individual form objects to their original display state

2009-03-10 Thread Nekura Neko
I'm thinking that $("form input").each(function() { $(this).val(origFormData[$(this).attr ("id")]); }); should step over each input field in a form and conjure up values from the origFormData object based on the id of the current element conjuring a value. But the state-saving code should be mo