How to separate fields in main screen and ionic modal? - ionic-framework

I am trying out the ionic modal to use for editing an item in my app. on my main screen, i configured a button to open a modal and pass the item details. here's the html code:
<button class = "button button-block" ng-click = "openModal(item)">
<div class="row">
<item class="col col-15">{{item.itemName}} </item>
<item class="col col-15">{{item.brand}} </item>
<item class="col col-5">{{item.size}} </item>
<item class="col col-15">{{item.quantity}}</item>
<item class="col col-15">{{item.threshold}}</item>
</div>
</button>
In my openModal function, I initialize itemdetail to display in my modal as follows:
$scope.openModal = function(item) {
$scope.itemdetail = item;
$scope.modal.show();
};
I am able to display the itemdetail properties in my modal and I have configured 2 fields in the modal as editable:
<form name="inventoryItemModal">
<div class="col">
<item class="row">
<item class="col">Brand : {{itemdetail.brand}} </item>
</item>
<item class="row">
<item class="col">Size : {{itemdetail.size}} </item>
</item>
<item class="row">
<div class= "col"> Quantity :
<input type="number" ng-model="itemdetail.quantity" step="1" max="99999999" ng-change='fieldchanged=true'>
</div>
<div class="col"> Threshold :
<input type="number" ng-model="itemdetail.threshold" min="1" step="1" max="99999999" ng-change='fieldchanged=true'>
</div>
</item>
</div>
<button class = "button button-{{colorTheme}}"
ng-disabled="!inventoryItemModal.$dirty || inventoryItemModal.$invalid "
ng-click = "processItem(itemdetail)">Update</button>
</form>
the problem is when I change the value of the quantity field but then click outside the modal to go back to the main screen, the main screen reflects the value changed in the modal even though I am using different variables in the main screen (item.quantity) and modal screen (itemdetail.quantity). Why is item.quantity changing?

I was able to fix this problem by changing the name of the input field in the modal from quantity to quantitymodal. I don't know why that is but it works.

Related

Template driven validations need to work in cancel button

In a form I have two buttons save and cancel. In the save button I have done validations for input and kendo date picker but the problem is
cancel button purpose is clear the input values.while clear the values automatically validation messages are showing.
How can I prevent the validations for cancel button in angular 6
<form (ngSubmit)="f.form.valid && saveFilter()" #f="ngForm" novalidate>
<div class="formNew">
<label for="name">Custom Filter Name:</label>
<input type="text" [(ngModel)]="filtername" name="filter" #filter="ngModel" placeholder="Filter name" maxlength="50" [ngClass]="{ 'custom-filtername': f.submitted && !filter.dirty}" required />
</div>
<kendo-datepicker class="kendoCalendarPickerBox" [ngClass]="{'custom-datepciker':f.submitted &&!isdatepicker.dirty &&!isChecked}" [(ngModel)]= "Datevalue" required></kendo-datepicker>
<div class="footer">
<span class="foot_left">
<button type="button" class="btn blueBtn lftBtn" (click)="FilterAction('Delete')">Delete</button>
</span>
<span class="foot_right">
<button class="btn blueBtn"> {{saveButtonName}}</button>
<button type="button" class="btn btnDefault" (click)="FilterAction('Cancel')">Cancel</button>
</span>
</div>
</form>

ionic keyboard moves content upwards

I'm a beginner on ionic framework. Just doing markup for the app not developing the whole application.
on focusing field the keyboard opens and pushed ion-footer upwards i have set position and bottom values but none of them is working.
Here is the code of the page.
<ion-pane class="login">
<ion-content class="has-footer" scroll="false">
<div class="row topgap">
<div class="col-80 col-offset-10">
<div class="fixWidthContainer">
<h2 class="text-center">Welcome to Givi</h2>
<input type="text" placeholder="Full Name" />
<input type="email" placeholder="Email" />
<input type="password" placeholder="Password" />
<br />
<button class="button button-full LoginButton">Sign up</button>
<button class="button button-full LoginButton facebook">Sign up using Facebook</button>
</div>
</div>
</div>
</ion-content>
<ion-footer-bar class="transparentfooter">
<button href="#" class="button footercustombutton">Login</button>
</ion-footer-bar>
</ion-pane>
Also when the keyboard opens the background value is cover is also adjust itself and get smaller. What to do with this...
check this value if its false change it to true
<preference name="Fullscreen" value="true" />

Space Key Disabled in Form in Bootstrap Carousel Slide

I have a form inside a Bootstrap carousel slide. I can not enter spaces in the text boxes in the fields and cannot see why. Here's my code:
<section class="carousel slide" data-ride="carousel" data-interval="false" data-wrap="false">
<div class="carousel-inner" role="listbox">
<div class="item active">
<form class="form-inline" name="myForm">
<div class="form-group">
<input name="title" type="text" class="form-control" />
</div>
<button type="submit" class="btn btn-success btn-link">Submit</button>
</form>
</div>
</div>
</section>
You can capture the spacebar keypress (code 32) and prevent the propagation to the carousel.
$('input').on('keydown', function (e) {
if (e.keyCode == 32) {
e.stopPropagation();
}
});
I would also prevent keyboard navigation on the carousel or people using the arrows might navigate through carousel slides.
<section class="carousel slide" data-ride="carousel" data-interval="false" data-wrap="false" data-keyboard="false">
Live example: http://www.bootply.com/phVgpOYnO0

bootstrap date picker popup

How can I move Date picker popup to show on right side? Currently it is making me to scroll page down to view the calendar.
<div class ="form-group">
<label class="col-sm-2 control-label" >Received Date</label>
<div class="col-sm-2 input-group date" data-date-format="mm-dd-yyyy">
<input class="text-input form-control" type="text" name="ARDT" id="ARDT" maxlength="10" />
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
2. How can size the application number filed width to 15 ?
<div class ="form-group">
<label class="col-sm-2 control-label" >Application Number</label>
<div class="col-sm-3">
<input class="text-input form-control" type="text" name="appNumber" id="appNumber" maxlength="15" size="15"/>
</div>
</div>
DEMO
Twitter bootstrap-3 datepicker has option "orientation":
A space-separated string consisting of one or two of “left” or
“right”, “top” or “bottom”, and “auto” (may be omitted); for example,
“top left”, “bottom” (horizontal orientation will default to “auto”),
“right” (vertical orientation will default to “auto”), “auto top”.
Allows for fixed placement of the picker popup.

Keep buttons and form with select dropdown on same row in Bootstrap 3

I'm struggling to keep buttons, and a form with a <select> tag (including its label) all on the same row in Bootstrap 3. Whenever the form is rendered, it seems to add a line break before the form. Here's what I have put together so far (http://www.bootply.com/98022):
<div class="container">
<div class="row">
<button class="btn btn-default">Test 1</button>
<button class="btn btn-default">Test 2</button>
<form role="form" class="form-inline">
<div class="form-group">
<label for="selectUser">Select:</label>
<select id="selectUser" class="form-control selectWidth">
<option class="">One</option>
<option class="">Two</option>
<option class="">Three</option>
</select>
</div>
<div class="btn-group">
<button class="btn btn-default">Test 3</button>
</div>
</form>
</div> <!-- End Row -->
</div> <!-- End Container -->
I thought that the class="form-inline" would keep it on the same row. Unfortunately, this is how it renders:
This is a mock-up I created in an image editing program of what I'd like it to look like:
I have deliberately chosen to use the <select> element instead of Bootstrap dropdowns, as the interface on mobile devices is optimal (the list will be quite large and trying to select the correct option on a small screen is easier with a form <select> element).
I found similar questions, but most either don't address the <select> tag within a form, or are for older versions of Bootstrap (2.x). Any help would be greatly appreciated.
Thanks!
Your first two button are not inside the form tag.
It seems form-inline does not define styles for labels, so add a left float some padding and set the width of the select to auto.
<div class="container">
<div class="row">
<form role="form" class="form-inline">
<button class="btn btn-default">Test 1</button>
<button class="btn btn-default">Test 2</button>
<div class="form-group">
<label for="selectUser" style="float:left;padding: 6px 12px 2px 12px;">Select:</label>
<select id="selectUser" style="width:auto;" class="form-control selectWidth">
<option class="">One</option>
<option class="">Two</option>
<option class="">Three</option>
</select>
</div>
<div class="btn-group">
<button class="btn btn-default">Test 3</button>
</div>
</form>
</div> <!-- End Row -->
</div> <!-- End Container -->