This is a migrated thread and some comments may be shown as answers.

Select All Text on Focus AngularJS

3 Answers 265 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Marc
Top achievements
Rank 1
Marc asked on 16 Feb 2017, 08:20 AM

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
})
});

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 20 Feb 2017, 08:10 AM

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.
0
Marc
Top achievements
Rank 1
answered on 21 Feb 2017, 07:43 AM

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

0
Anton Mironov
Telerik team
answered on 16 Sep 2020, 01:18 PM
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/.

Tags
NumericTextBox
Asked by
Marc
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Marc
Top achievements
Rank 1
Anton Mironov
Telerik team
Share this question
or