PDA

View Full Version : Blocking an event from bubbling up



j11extjs
14 Oct 2010, 2:00 AM
I have a submit button in my page that causes a postback. If the operation is successfull, the page closes. I have 2 questions.

1) I want to perform an operation first and if this operation is successful, I want the post to proceeed. Thus the following code:


var listenToSubmit = function(){
var btnSubmit = Ext.get('btnSubmit');

var onClickSubmit = function(){
if(onValidate()==true)
{
//PerformSomething();
//Go forward with the submit;
}else{
//Do not go forward with the submit by stopping the click event from bubbling up?
}
}

btnSubmit.on('click', onClickSubmit)
}


In the else-block, how do I stop this 'click' event such that the post will not go through?

2. When the post goes through and is successful, how do I trap this http so I can do something else before the page is closed? The reason being is that I want to be able to do PerformSomething() after the postback instead.

Thanks in advance.

Animal
14 Oct 2010, 2:13 AM
Not sure you are on the right track unless you are in fact using Ext Core and not Ext JS.

Ext.get on a <button> element?

You should use an Ext.Button configured with a handler.

j11extjs
14 Oct 2010, 5:25 AM
Thanks for the reply. No the button is an asp server control button. Basically my first question is how do I pass the 'click' event object inside the onClickSubmit function so that I can call eventObj.stopEvent() inside the else-block.

Animal
14 Oct 2010, 5:50 AM
"asp server control button"?

What's one of them?

Events are passed to handlers. You know that? You must have read the docs for on() in order to use it.

But this is all wrong "asp server control button"? What's that all about?