attachEvent - onButtonClick

Hi,

is there an working example for the event ‘onButtonClick’? I like your buttons for submit, but I can’t send data, because the event is never call ( I use firebug for see any action, when I click the buttons in your examples … but nothing). I have click the button ever and ever … :confused:

Thanks!

Hello,

Works fine on our side, please check attached demo.
25.zip (27.3 KB)

thanks andrei,

the point is, it works fine with JSON init! I have try with the HTML init:

dhxList = new dhtmlXForm("listObj");
dhxList.attachEvent("onButtonClick", ...);

...

<div id="listObj">
	<ul class="dhtmlxForm">
		<li ftype="button" name="close" value="Close" command="close" />
	</ul>
</div>

and the event don’t work!

In the js-source (dhtmlxform.js) it call the _onButtonClick event. But, by the next step, the onButtonClick event is unknow by the object (this).

For the first time, I fix my problem by using the json init. Maybe someone will fix the problem.

Thanks in advance!

Dirk

Hello,

Thanks for your info.

Actually onButtonClick event is called for UL init too, but in case of this init there is no shared form instance to call attachEvent(“onButtonClick”,function(){}) to attach user handler.

We’ll add it, but if you need working UL init right now, we can create a demo for you.

Hi,

Thanks, but your work is really good enough for me! I work with the json init and this work fine for me! If you add these feature in the next release - everything is okay :wink:

Dirk

I would loveto continue using the HTML init, but get a form instance handle to manipulate and attach events…could you please create a demo of this?

Please use attached dhtmlxform.js file

<ul class="dhtmlxForm" name="myForm" oninit="doOnInit('myForm');">
...
</ul>

After init, doOnInit will called and form will available through window.myForm:

function doOnInit(formName){
    window[formName].attachEvent("onButtonClick", function(){
        // code here
    });
}

Missed attachment
dhtmlxform.js.zip (13.8 KB)

Thanks for the code.
I am having a few problems enabling validation on a “UL Init” constructed form, using the init procedure below:

  • This is a HTML code fragment for UL:
  • Card Number
  • This is the Jscript:
    function doOnULInit( formName ){
    var dhxFormSearchWinObj = window[formName];
    dhxFormSearchWinObj.setSkin(‘dhx_black’);
    dhxFormSearchWinObj.attachEvent(“onValidateError”, function (input, value){
    alert(‘input=’+input+’ value=’+value);
    });
    }

  • Two issues:
    (1) When I click “Search Now” I do not get a validation error on the empty text input field.
    So I’m not sure that command=“validate” works or validate=“NotEmpty” is recognized.
    (2) The alert message on attachEvent is not triggered when I submit on empty text field.
    But setSkin() function does work, so I know that attachEvent() is executed.

Any ideas what I am doing wrong?