Categories | Question details Back To List | ||
onChange event and setComboValue I've created a combo and attached an event, but when I call setComboValue (also tried setComboText and DOMelem_input.value) it doesn't call the attached function. Below is a sample. function Event() {} Event.prototype.handler = function() {}; var myEvent = new Event(); var combo = new dhtmlXCombo(...); combo.loadXML(...); combo.attachEvent('onChange', myEvent.handler); combo.setComboValue('hello'); The event doesn't fire when setComboValue is called, but I can click on the combo and tab away and the event fires for the new value. Can you tell me if this doesn't work like I think it should or if I am doing something wrong? Answer posted by Support on Apr 04, 2008 10:29 onChange event will be fired in next situations - option selected by mouse click - option selected by keyboard and enter key pressed - option selected by keyboard and tab pressed or focus moved out from control Event will not be fired on API calls. Answer posted by Chris Pijl on May 19, 2009 06:24 Has this changed since last year? Cuz I've got this: (well basically it comes down to this...) co.attachEvent("onChange",function(){ lo.setComboValue(-1); pr.setComboValue(-1); } lo.attachEvent("onChange",function(){ alert('Changed!'); } pr.attachEvent("onChange",function(){ alert('Changed too!'); } And the alerts keep popping up when I change the co-combobox value... Answer posted by Chris Pijl on May 19, 2009 06:26 Ow and I forgot to mention, I don't want them to activate! Answer posted by Alex (support) on May 19, 2009 07:11 Try to use the following instead lo.setComboValue(-1); pr.setComboValue(-1); lo.selectOption(lo.getIndexByValue("-1"),false,false); pr.selectOption(lo.getIndexByValue("-1"),false,false); Answer posted by Chris Pijl on Jun 09, 2009 05:22 Great works like a charm! Cheers! |