Skip to content

Commit c882787

Browse files
author
Nathan McMinn
committed
Bug fix to dependent select control
Initial state behavior was inconsistent.
1 parent b1066ef commit c882787

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

pdf-toolkit-share/src/main/resources/META-INF/pdftoolkit/components/doclib/pdftoolkit-doclib-actions.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,22 @@ PDFToolkit.Util = {};
238238

239239
onReady: function DependentSelect_onReady()
240240
{
241-
YAHOO.util.Event.addListener([this.id], "change", this.toggleDependentFields, this);
241+
YAHOO.util.Event.addListener([this.id], "change", this.onChange, this);
242+
var select = YAHOO.util.Dom.get(this.id);
243+
this.toggleDependentFields(this.options.showSelectValues, select, this.options.htmlId);
242244
},
243245

244-
toggleDependentFields: function DependentSelect_toggleDependentFields(event, that)
246+
onChange: function DependentSelect_onChange(event, that)
245247
{
246248
var config = that.options.showSelectValues;
249+
var htmlId = that.options.htmlId
250+
var select = event.srcElement;
251+
252+
that.toggleDependentFields(config, select, htmlId);
253+
},
254+
255+
toggleDependentFields: function DependentSelect_toggleDependentFields(config, select, htmlId)
256+
{
247257
// anything assigned to another show value will be hidden
248258
for(index in config)
249259
{
@@ -253,11 +263,11 @@ PDFToolkit.Util = {};
253263

254264
// if the event source is the right option, show the fields
255265
// if it is not, hide these fields
256-
if(name === event.srcElement.value)
266+
if(name === select.value)
257267
{
258268
for(fieldIndex in fields)
259269
{
260-
var field = YAHOO.util.Dom.get(that.options.htmlId + "_" + fields[fieldIndex]);
270+
var field = YAHOO.util.Dom.get(htmlId + "_" + fields[fieldIndex]);
261271
var container = field.parentElement;
262272
container.style.display = 'block';
263273
}
@@ -266,7 +276,7 @@ PDFToolkit.Util = {};
266276
{
267277
for(fieldIndex in fields)
268278
{
269-
var field = YAHOO.util.Dom.get(that.options.htmlId + "_" + fields[fieldIndex]);
279+
var field = YAHOO.util.Dom.get(htmlId + "_" + fields[fieldIndex]);
270280
var container = field.parentElement;
271281
container.style.display = 'none';
272282
}

0 commit comments

Comments
 (0)