Select All Text on Focus AngularJS

4 posts, 0 answers
  1. Marc
    Marc avatar
    171 posts
    Member since:
    Sep 2016

    Posted 16 Feb 2017 Link to this post

    The details here, do not seem to work for AngularJS implementation. Nothing happens, and none of my log messages are shown on click or focus.

    http://docs.telerik.com/kendo-ui/controls/editors/numerictextbox/how-to/select-all-on-focus

    My Html:

    <input kendo-numeric-text-box
    k-min="0"
    k-ng-model="params.averagePrice.max"
    style="width: 45%;"
    k-format="'n1'"
    k-step="0.1"
    k-on-change="maxChange(params.averagePrice)"
    k-on-spin="maxChange(params.averagePrice)"/>

     

    Inside my Angularjs Controller:

    $(document).ready(function () {
    $("input[type=text]").bind("focus", function () {
    $log.info("bind focus ");
    var input = $(this);
    clearTimeout(input.data("selectTimeId")); //stop started time out if any

    var selectTimeId = setTimeout(function () {
    input.select();
    });

    input.data("selectTimeId", selectTimeId);
    }).blur(function (e) {
    $log.info("bind blur");
    clearTimeout($(this).data("selectTimeId")); //stop started timeout
    })
    });

  2. Ianko
    Admin
    Ianko avatar
    1940 posts

    Posted 20 Feb 2017 Link to this post

    Hello Marc,

    With AngularJS, you should rather use the global kendoWidgetCreated event to interact with widgets on initialization.

    http://dojo.telerik.com/uXogi 

    Regards,
    Ianko
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Marc
    Marc avatar
    171 posts
    Member since:
    Sep 2016

    Posted 21 Feb 2017 in reply to Ianko Link to this post

    Hi Ianko,

    I had done that, but still had some issues. In the end, I believe my issue was due to the architecture of my page. (I have numerous Angular directives which had the multiselects inside , and I wanted to clear these multiselects from outside those directives). I used a watch inside each directive and got it to work that way.

    Thanks for the help though!

    Marc

  4. Anton Mironov
    Admin
    Anton Mironov avatar
    72 posts

    Posted 16 Sep Link to this post

    Hi,

    I would like to share with you that as of Kendo UI version 2020.2.617, our team has added the "selectOnFocus" property covering the pointed requirements in this thread.  For your future web development, feel free to utilize this implementation shown here:
    <input id="numerictextbox" />
    <script>
    $("#numerictextbox").kendoNumericTextBox({
        selectOnFocus: true
    });
    </script>
    If you have any questions about the new functionality don't hesitate to contact our team.

     

    Kind Regards,
    Anton Mironov
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top