【问题标题】:Kendo IntegerTextBoxFor select all numbers on focusKendo IntegerTextBoxFor 选择焦点上的所有数字
【发布时间】:2014-07-30 12:00:44
【问题描述】:

我看过很多关于使用 jQuery 为常规输入框选择所有文本的精彩帖子...

$("input[type='text']").on("click", function () {
   $(this).select();
});

以上方法非常适合

  @Html.TextBoxFor(...etc

但不适用于:

@Html.Kendo().IntegerTextBoxFor(...

 @Html.Kendo().CurrencyTextBoxFor(...

我试着看看剑道中是否有我可以附加的焦点事件,所以我可以全选,但没有乐趣。

有趣的是,渲染的输入控件确实有 type="text" 所以 jQuery input[type='text'] 应该可以工作......但没有。

有人找到适合这些人的东西吗?

【问题讨论】:

    标签: selection kendo-asp.net-mvc onfocus


    【解决方案1】:

    我不确定这是否真的有效,但可能会让你开始。

    要对 Kendo 渲染控件进行 [大量],您必须执行以下操作:

    var control = $('#my-control').data('kendoNumericTextBox');
    

    然后您可以在control 上调用方法/属性。

    因此,在这种情况下,可能会起作用:

    var control = $('#my-control').data('kendoNumericTextBox');
    control.focus();
    

    NumericTextBox 的 API 文档可以在这里找到http://docs.telerik.com/kendo-ui/api/web/numerictextbox#methods-focus

    【讨论】:

    • Telerik 论坛中的类似帖子支持您的回答并对其进行了扩展:function selectText(e) { $(e.container).find(".k-input.k-textbox").select (); $('.k-input').on('focus', function () { var input = $(this); setTimeout(function () { input.select(); }); }); }
    猜你喜欢
    • 2011-09-01
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 2011-05-08
    • 2017-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多