Parabellum1905y / ufd

Automatically exported from code.google.com/p/ufd
GNU General Public License v2.0
0 stars 0 forks source link

create an option firstEmpty to automatically create an empty element as first element #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be nice to create an option like
 firstEmpty : true

(which maybe by default is false)
to automatically create a blank <option> on the top of the select on UDF 
init.

Original issue reported on code.google.com by francesc...@gmail.com on 18 Dec 2009 at 8:44

GoogleCodeExporter commented 8 years ago
If you want, i can try to make a patch for this

Original comment by francesc...@gmail.com on 19 Dec 2009 at 1:04

GoogleCodeExporter commented 8 years ago
It's not very wise.
The purpose of this plugin - to "decorate" the existing <select> without 
modifying it's 
standard behaviour (let's ignore filtering for a minute). So it's 
1. not a defect,
2. it's better to add an "<optoion>Select something</option>" in the 
server-side code, 
rather than increasing complexity with this feature.
3. the right implementation would be not adding a new option, but just modify 
function 
"setInputFromMaster" to make it set "this.input.val('');" if an option is set.

Original comment by Erel...@gmail.com on 20 Jan 2010 at 10:59

GoogleCodeExporter commented 8 years ago
Doing this is in effect adding a new option element, as the list is backed by 
and
reflects the real select list; this is the "unobtrusive" part of the name. 

If you want the user to be able to submit an empty value - add it in the 
original. 
You can then have a value submit (e.g. <option value="-1"></option>) and your 
server
can interpret it as needed.

if you really want clientside to add the empty value, just do this:

$("select").prepend("<option value="-1"></option>");

Original comment by thetoolman on 4 Feb 2010 at 6:58