旋转事件不会在第一次在jQuery Spinner中触发 [英] spin event doesn't trigger at first time in jquery spinner

查看:116
本文介绍了旋转事件不会在第一次在jQuery Spinner中触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个自定义微调器,该微调器在数字后附加一个字符串.

I have created a custom spinner which appends a string after a number.

var percent = 5.5%;
$.widget("ui.pcntspinner", $.ui.spinner, {
        _format: function(value){
            return value + " %";
        },

        _parse: function(value){
            return parseInt(value);
        }
    });


    $("#spinner").pcntspinner().val(percent);

微调框有两个附加事件,即聚焦和旋转. focusout在第一次调用时也能正常工作,但是旋转不会在第一次触发.仅在触发任何其他事件之后,才会调用旋转.有解决这个问题的主意吗?

The spinner has two events attached to it i.e. focusout and spin. focusout works fine in first call too, but spin does not gets triggered at first time. Only after any other event has been triggered does the spin gets called. Any idea to solve this problem?

推荐答案

找到了解决方案.我还是不明白为什么旋转不是第一次触发的,但这很有帮助-

Found the solution. I still don't understand though why spin was not getting triggered the first time but this helped -

var percent = 5.5%;
$.widget("ui.pcntspinner", $.ui.spinner, {

         widgetEventPrefix: "spin",
        _format: function(value){
            return value + " %";
        },

        _parse: function(value){
            return parseInt(value);
        }
    });


    $("#spinner").pcntspinner().val(percent);

这篇关于旋转事件不会在第一次在jQuery Spinner中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆