I'm having some trouble submitting a form in a Bootstrap modal using AngularJS. The user is currently able to mash the submit button a few times before the modal dismisses and call the submit function each time. This is obviously not desired behaviour.
So I tried adding data-ng-disabled to the button, and disabling it when the submit button is clicked. This works correctly and the user cannot submit more than once. But now the modal does not close, even using data-dismiss="modal" with the button. I've read about AngularUI Bootstrap but if there's a way to fix this without changing my modals that would be great.
A snipper of the submit button in the modal:
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" data-ng-disabled="isDisabled" ng-click="disableButton(); submit()">Submit</button>
<button class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
The disableButton() function:
$scope.disableButton = function(){
$scope.isDisabled = true;
}
You need to use the name of your form and use that for ng-disabled, then use the $invalid Input State validation, see below:
<button type="button" class="btn btn-primary" ng-disabled="myForm.$invalid" ng-click="submit()">Submit</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
Related
I Have a situation based on the sum of a group textboxes the button should be enabled and disabled in angularjs
<button type="button" class="btn btn-primary" ng-disabled="{{goalAA-goalAB--goalAC--goalAD--goaAE}} > 100" ng-click=clicked()>Save changes</button>
if the value is more than 100 the disabled is not set to true
the fiddler goes here JSFIDDLE
Remove square brackets in ng-disabled. You can find more information about ng-disabled directive in angularjs documentation.
<button type="button" class="btn btn-primary" ng-disabled="goalAA-goalAB--goalAC--goalAD--goaAE > 100" ng-click="clicked()">Save changes</button>
Demo
I have two buttons in angularjs to activate and deactivate user my problem is I want to make one button when I click the button change her color and text I try to change but no success.
Someone correct me my Attempt
This is my two button :
<input type="button" class="btn btn-success" value="Active" ng-click="Active(User)" />
<input type="button" class="btn btn-danger" value="Desactive" ng-click="Desactive(User)" />
I try to change them but I don't know what the problem :
<div ng-class="User.IsActive? 'btn btn-success' : 'btn btn-danger' "
ng-click="User.IsActive?Active(User):Desactive(User)">
{{ User.IsActive ? 'Active' : 'Desactive'}}
</div>
I am trying to create a form with two buttons Edit & Submit. Submit is initially disabled . What I need to achieve is when Edit is clicked Submit button should be enabled and edit is disabled. Here is my code so far:
<div class="row">
<button id="editBtn" type="button" data-dismiss="modal" (click)="submitEditedFormData()" class="btn modal-btn btn-default">Edit</button>
<button id="submitBtn" [disabled]="!isValid" type="button" data-dismiss="modal" class="btn modal-btn btn-default">Submit</button>
</div>
You can toggle the value of isValid when you click on edit button and you can do the same when you click on submit by adding a (click) event.
<div class="row">
<button id="editBtn" type="button" data-dismiss="modal" (click)="submitEditedFormData();isValid=!isValid" class="btn modal-btn btn-default" [disabled]="isValid">Edit</button>
<button id="submitBtn" [disabled]="!isValid" type="button" data-dismiss="modal" class="btn modal-btn btn-default">Submit</button>
</div>
I am trying to identify a button which looks like
<span class="btn btn-default fileinput-button" title="Add files…">
<i class="icon-plus"></i>
<span>Add files…</span>
<input id="fileUploadComponent" type="file" name="files[]" multiple="">
</span>
I am trying to identify this button with
//input[#type='file']" selector="Xpath"
input[id='fileUploadComponent'][#type='file'] Selector Css
input[id='fileUploadComponent'] Selector Css
I don't get any exception, instead in my log it shows the element is clicked but nothing happens in the page (button is not clicked)
I'm trying to add angular-bootstrap tooltip in each button of button-group. When I do this, hovering right button destroys all buttons styles.
html:
<div class="btn-group" style="margin-top:100px;">
<label class="btn btn-primary" tooltip="{{dynamicTooltip}}" ng-model="radioModel" btn-radio="'Left'">Left</label>
<label class="btn btn-primary" tooltip="{{dynamicTooltip}}" ng-model="radioModel" btn-radio="'Middle'">Middle</label>
<label class="btn btn-primary" tooltip="{{dynamicTooltip}}" ng-model="radioModel" btn-radio="'Right'">Right</label>
</div>
js:
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('TooltipDemoCtrl', function ($scope) {
$scope.dynamicTooltip = 'Hello, World!';
});
Here is my plunker: http://plnkr.co/edit/NFjJJXEKyJHDgddcPdNa?p=preview
It's because your tooltip is generating inside the btn-group. This means the 'Right' button is no longer the last element in the group, as such the styling changes until the tooltip disappears. Try appending the tooltip to the body, rather than the parent.
<label class="btn btn-primary" tooltip="{{dynamicTooltip}}" tooltip-append-to-body="true" ng-model="radioModel" btn-radio="'Right'">Right</label>