PDA

View Full Version : 2 buttons 1 handle



billhamawi
6 Jan 2014, 7:42 PM
Hey guys i am new to extjs (fresh out of study) and my js is not the best.


Q. how do i go about adding 1 handler to two buttons to check whether button one was clicked or button two clicked. I need the first button to disable the second button.

example.

var btn1, btn2, clickedbutton;

btn1 ={
handler : clickedbutton =1
}

btn2 = {
handler : clickedbutton = 2
}
if(clickedbutton = 1)
function(button)
{
do some code
}

I am editing some else's code and this is only logical thing i could think of, after i have exhausted all my avenues.

any help will be appreciated.

alexander.urban
7 Jan 2014, 12:01 AM
var btn1, btn2, clickedbutton;
btn1 ={
handler : function() { clickedbutton(1); }
}
btn2 = {
handler : function() { clickedbutton(2); }
}

clickedbutton:function(btn) {
//do some code both btns
if(btn == 1) {
//do some code btn1
} else {
//do some code btn2
}
//do some code both btns
}
If you don't have any "code both btns", you better do two different handlers:

btn1 ={
handler : function() {
//do some code btn1
}
}
btn2 = {
handler : function() {
//do some code btn2
}
}

billhamawi
7 Jan 2014, 2:43 AM
thank you.... really helped