1
I’m trying to block the click on one input
Html
<input id="txtData" class="form-control" /><span class="input-group-addon" data-role="data"><i class="glyphicon glyphicon-th"></i></span>
So that no action happens when the input
was clicked, already tried the following code and was unsuccessful.
$('#txtData').click(function (event) {
event.preventDefault();
event.stopPropagation();
return false;
});
*Obs: I’ve tried with delegate
and onclick
also.
I have a datepicker
engaged in the input
, it’s triggered when I click somewhere else ($('#txtData').datepicker("show");
), I have also searched properties of datepicker
and there’s none that makes him invisible or something like that, possibly the click triggers the datepicker
before performing my function jquery
, would have some way to block the click 100% before, during and after any suggestions?
Tried the properties
disabled
orreadonly
of the HTML itself?– BrTkCa
I just tried, changed the cursor as the field was blocked even, but keeps opening the datepicker, how crazy.
– Mathiasfc
Tried to remove the event from her click? Because as you use a datepicker on it, datepicker will attach the click event when it is loaded.
– André Luis Marmo
But I need the datepicker in it, but I just want to trigger the datepicker from somewhere else, eg: click a button on the screen, open it from somewhere else already getting the problem is that I did not want to open by clicking on the same input, If I take the datepicker from the input there is nothing else works and if I put the datepicker on the button I want it opens all deformed. @Andréluismarmo
– Mathiasfc
You may not assign the datepicker to it, since you want to open elsewhere, and in the datepicker event of: onSelect, set the selected date..
– Aline
I need to assign the datepicker to it because when selecting a date the date will be displayed in the input, and assigning the datepicker to a button for example it is completely deformed. @Aline
– Mathiasfc
Can’t you elaborate a minimal, verifiable example to include in the question? Using Sopt’s HTML snippet can be a good one.
– Woss
Yes, I am going to do that, at the moment I cannot, but as soon as I do I will supplement the question with a snippet. @Andersoncarloswoss
– Mathiasfc
At first the
disabled
should work: see.– Woss
In datepicker you have an option: onSelect, just take the value and assign to inpt when the user selects.
– Aline
Kd Bacco with XY problem link? : ) The problem seems q is to disable a button that activates Date Picker. You couldn’t suddenly hide it all with a:None display or visibility:Hidden from css and then give it a display:block or visibility:Visible when it had to appear?
– Antonio Alexandre