有没有什么办法可以知道某个按钮是否在确定的时间点击? 我有两个递增和递减按钮(加号和减号)来控制Ajax请求的温度。该值与下一个函数一对一地递增:有没有什么办法可以知道一个按钮没有按下确定的时间点击?
Plugin_increment.prototype.startPluginTempe = function (selector, dataAux, dataAux2, varAux, varAux2) {
var valueElement = $(selector);
function incrementValue(e){
if((valueElement.text() < 40) && (valueElement.text() > 10)){ //max and min
valueElement.text(Math.max(parseInt(valueElement.text()) + e.data.increment));
}
if(valueElement.text() == 40){//max
if(e.data.increment == -1){
valueElement.text(Math.max(parseInt(valueElement.text()) + e.data.increment));
}
}
if(valueElement.text() == 10){//min
if(e.data.increment == 1){
valueElement.text(Math.max(parseInt(valueElement.text()) + e.data.increment));
}
}
//Ajax request??????
return false;
}
$(varAux).button({
icons: {
primary: "ui-icon-plusthick"
},
text: false
}).bind('click', {increment: 1}, incrementValue);
$(varAux2).button({
icons: {
primary: "ui-icon-minusthick"
},
text: false
}).bind('click', {increment: -1}, incrementValue);
};
“selector”是显示值的跨度选择器。 “varAux”和“varAux2”是加号和减号按钮的选择器。
如果我为每个增量发送一个Ajax请求,客户端将被重载。我认为,一个选项可能是知道按钮是否没有被点击确定的时间。其他方式?
我使用jquery-ui加号和减号按钮。
为什么在ajax请求完成之前不关闭按钮? – 2013-03-01 13:11:44
因为增量是一对一的,所以如果我想增加五个统一体的价值。将有五个Ajax请求。将会有不必要的请求 – vicenrele 2013-03-01 16:37:32