Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

formHash function does not set the values if the value is empty string


Project:Field Plug-in
Version:0.7
Component:Code
Category:bug report
Priority:critical
Assigned:DanSwitzer2
Status:closed
Description

I am not sure about the behaviour.

I am using the plugin to store the form, and restore it back if needed,
unfortunatelly I have a input text box, which is empty, the state got saved perfectly,
but if the user enters some values into the form input box,

then I restore the state calling

$myForm.formHash(savedValues); it does not set the empty string on the element.

I checked the code. it is in line 288

} else if( !!inHash[n] ){
jel[defaults.useArray ? "fieldArray" : "setValue"](inHash[n]);
}

I see the purpose was to avoid overwriting a value with an undefined in the hash.
although this unfortunately does not set the value if the value is in the hash but empty.

if the hash has something like this

{
  myinputtext = ""
}

this will also be skipped, I am not sure if this is the intended or a bug.

for me I need to set back the input box to it's empty state.

of course it can happen that the form has some elements that is not defined in the passed in hash. to sort this problem out I did the following ->

} else if( eval("inHash."+n) !== undefined ){
jel[defaults.useArray ? "fieldArray" : "setValue"](inHash[n]);
}

I do not want to post this as a patch, as I am a java developper totally new to JS, and I am not sure this is the best solution to check if an assoc array has such a field or not.

I am looking forward to see a better solution.

Thanks a lot

Istvan

Comments

#1

I think this is nicer like this :)

} else if( inHash[n] !== undefined ){
jel[defaults.useArray ? "fieldArray" : "setValue"](inHash[n]);
}

#2

Assigned to:Anonymous» DanSwitzer2
Status:active» fixed

This was actually fixed in v0.7.1 (which is on my site.)

#3

Status:fixed» closed