Phonegap how to auto show keyboard - ios

I have a phonegap application using Angular. The problem I'm having is that I want to allow user to enter their email in a form inside a modal.
$scope.email = function () {
$uibModal.open({
animation: true,
templateUrl: 'views/modals/sales/email.html',
size: "md",
windowClass: 'center-modal',
controller: function ($scope, $uibModalInstance) {
//$("#email").focus();
$scope.submit = function () {
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
}
}
});
};
Now the template for that modal is this.
<div class="panel panel-primary">
<form name="form" ng-submit="submit(form)" novalidate>
<div class="panel-body">
<div class="col-md-12">
<h3 class="text-center">Please enter your email</h3>
</div>
<div class="form-group col-md-12">
<input type="email" class="form-control btn-block input-lg" ng-model="customer.email" id="email" autofocus>
</div>
<div class="col-md-3 col-md-offset-6">
<button class="btn btn-default btn-block btn-lg" type="button" ng-click="close()">Close</button>
</div>
<div class="col-md-3">
<button class="btn btn-primary btn-block btn-lg" type="submit" ng-click="submit()">Send</button>
</div>
</div>
</form>
</div>
The problem that as you can see the input type email need to be focus when the modals open up, but instead my input is getting focus but the virtual keyboard on iOS is not showing up until I manually tap on the input.
How can I show up the virtual keyboard when the modal opens up.
thanks.

install the below cordova plugin
https://github.com/driftyco/ionic-plugin-keyboard
call cordova.plugins.Keyboard.show()

Related

Angular 7 Reactive Form returns previous entered value on Pressing Enter key

I have created a login form using angular reactive form. I've facing some strange behavior
If I submit the form using the submit button, I get the latest values which I've entered. If I submit the form using Enter key, then the value received is not latest. I've added the code below, can anyone pls suggest what i'm doing wrong.
ngOnInit() {
this.loginForm = this.formBuilder.group(
{
username: new FormControl(),
password: new FormControl(),
RememberMe: []
},
{
updateOn: 'blur'
}
);
}
login() {
const formvalue = this.loginForm.value;
console.log(formvalue);
return;
}
<div class="limiter">
<div class="container-login100 img-bg">
<div class="wrap-login100">
<img class="logo-center" src="../../../../assets/images/logo-big.png" />
<form [formGroup]="loginForm">
<div class="ui segment">
<h2>Login Form</h2>
<div class="ui form" >
<div class="required inline field">
<label>Username</label>
<div class="ui left icon input">
<i class="user icon"></i>
<input type="text" name="Username" placeholder="username" formControlName="username" >
</div>
</div>
<div class="required inline field">
<label>Password</label>
<div class="ui left icon input">
<i class="lock icon"></i>
<input [type]= "'password'" placeholder="password" formControlName="password" >
</div>
</div>
<div class="field login-ckeck">
<sui-checkbox>
Remember me
</sui-checkbox>
</div>
<button [ngClass]= "'ui primary button'" (click)= "login()">Submit</button> Forgot your password?
</div>
</div>
</form>
</div>
<!-- <footer class="footer">footer</footer> -->
</div>
</div>
Found the solution, it was an error from my side.
I had to change the updateOn to submit, for my code to work
this.loginForm = this.formBuilder.group(
{
username: new FormControl(),
password: new FormControl(),
RememberMe: []
},
{
updateOn: 'submit'
}
);
You can listen to either the forms (ngSubmit) or directly to the (keyup.enter) event and trigger the event then.
<form (ngSubmit)="login()">
<form (keyup.enter)="login()">

Select dropdown not displaying properly in the cshtml View

The dropdown on the image below do not display properly. I want the dropdown to cover the length of the Modal Popup. The Button on the page fire properly I have no issue with my Controller. Any help to resolve this issue will be appreciated
View Code
<a class="btn w-xs btn-primary" data-toggle="modal" data-target=".bootstrapmodal"><i class="fa fa-book" aria-hidden="true"></i><span id="#ViewBag.Group"> Add New Member</span></a>
<div class="modal fade bootstrapmodal ">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button data-dismiss="modal" class="close"><span>×</span></button>
<div class=" modal-title"><h3>Add User to Active Directory Group #ViewBag.Group </h3></div>
</div>
<div class="modal-body">
<div class="content">
#using (Html.BeginForm("AddNewUser", "ActiveDirectoryMember", FormMethod.Post, new { enctype = "multipart/form-data", id = "addUser" }))
{
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
#Html.AntiForgeryToken()
<div class="panel ">
<div class="panel-body ">
<div class="form-horizontal">
<input type="hidden" name="groupName" value="#ViewBag.Group" />
<div class="form-group">
#Html.Label("Technician", new { #class = "control-label col-md-2 required" })
<div class="input-group">
<div class="col-md-8">
<select id="userId" name="userId" class="form-control s2-search-box2">
<option value="">Click search for a staff member</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-2">
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-success" id="addUser">
<i class="fa fa-plus-circle"></i>
Add New User
</button>
</div>
</div>
</div>
</div>
</div>
}
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">
<i class="fa fa-ban"></i>
Cancel
</button>
</div>
</div>
</div>
</div>

bootstrap modal with asp.net mvc html helpers

I am trying to implement bootstrap ui modal in asp.net mvc. I created a basic modal which contains a login form.
Issue I am facing here is, when I start using html helpers, styles of the modal form is going really bad. I have attached screenshots below. one screenshot with when I don't use HTML helpers and that's when UI is more clean to view, when I add html helpers, style is going way off.
I have tried pretty much everything I can. I am unable to spot the issue. can someone please have a look at it and throw a light on where I am going wrong.
<div>
#using(Html.BeginForm()){
<div class="modal-header modal-hd-bg">
<button type="button" class="close" ng-click="cancel()">×</button>
<h3 class="modal-title">Login</h3>
</div>
<div class="modal-body">
<form novalidate class="form-horizontal" role="form">
<div class="form-group">
#*<label class="control-label col-sm-3" for="email">Email:</label>*#
#Html.Label("Email:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#* <input type="email" class="form-control" id="email" placeholder="Enter email" ng-model="luser.email">*#
#Html.TextBoxFor(m => m.email, new { #class="form-control", #placeholder="Enter Email", #id="email" })
</div>
</div>
<div class="form-group">
#*<label class="control-label col-sm-3" for="pwd">Password:</label>*#
#Html.Label("Password:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#*<input type="password" class="form-control" id="pwd" placeholder="Enter password" ng-model="luser.pwd">*#
#Html.TextBoxFor(m => m.pwd, new { #class="form-control", #placeholder="Enter password", #id="pwd" })
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary" ng-click="login()">Login</button>
</div>
</div>
</form>
</div>
<div class="modal-footer modal-ft-bg">
<label><u>Don't have an account</u>?</label>
<button class="btn btn-success" ng-click="goToRegister()">Register</button>
</div>
}
</div>
This is when I use #using(Html.BeginForm()) and html helpers
This is when I don't use HTML helpers)
No need for a form outside another form, because the outside form does not take any input. Nothing wrong with the html helpers.
HTML:
<div id="thisModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header modal-hd-bg">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="gridSystemModalLabel">Login</h3>
</div>
<div class="modal-body">
<form novalidate class="form-horizontal" role="form">
<div class="form-group">
#Html.Label("Email:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#Html.TextBoxFor(m => m.email, new { #class="form-control", placeholder="Enter Email", id="email" }
</div>
</div>
<div class="form-group">
#Html.Label("Password:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#Html.PasswordFor(m => m.pwd, new { #class="form-control", placeholder="Enter password", id="pwd" })
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</div>
</form>
</div>
<div class="modal-footer modal-ft-bg">
<label><u>Don't have an account</u>?</label>
<button class="btn btn-success">Register</button>
</div>
</div>
</div>
</div>

ReactJS.NET : Unable to get click events to fire

I'm running ReactJS.NET with ASP.NET MVC, and everything renders well, except... i cannot get any kind of events to fire...
What i have tried :
1) Eliminating all JQuery references/usages - no success
2) onHover, onClick, with functions both inside and outside of the React-component - no success
Here is my code :
Attaching ProductLine React component in index.cshtml
#Html.React("ProductLine", Model)
React component
function addToCart() {
alert("Hoohohoho!!!");
};
var ProductLine = React.createClass({
render: function () {
return(
<div className="col-md-12 col-sm-12 col-xs-12" key={this.props.productData.name}>
<button onClick={this.addToCart}>Click me!</button>
<div className="row" >
<div onClick={addToCart} className="col-md-12 col-sm-12 col-xs-12 nopadding row-default" >
<div className="col-md-3 col-sm-5 col-xs-5 nopadding">
<span className="table table-col ">
<input type="checkbox" id="cbxCheck2" className="jq_select_product" />
<label htmlFor="cbxCheck2" className="jq_select_product">{ this.props.productData.name }</label>
</span>
</div>
<div className="col-md-4 hidden-sm hidden-xs nopadding">
<span className="table table-col table-text-small">
{ this.props.productData.label }
</span>
</div>
<div className="col-md-3 col-sm-4 col-xs-4 nopadding">
<span className="table table-col">
849,- (12 mnd)
</span>
</div>
<div className="col-md-2 col-sm-3 col-xs-3 nopadding">
<span className="table table-col table-text-small text-right">
<img id="imgShowMore" src="../../Images/arrow_purple_down.png" className="show-more _icon jq_expand_listview" /><label className="show-more _lbl jq_expand_listview">Vis mer</label>
</span>
</div>
</div>
<ProductDetails productData={this.props.productData} />
</div>
</div>
);
},
addToCart: function (e) {
alert("Hooooo!!!");
},
});
After 1/2 a day of trial and error, i suddenly tried to put all the JSX file references at the bottom of the _Layout.cshtml page...
That solved it all actually...

UI.bootstrap.modal wont open when using latest versions of libraries

I am trying to do this under ASP.NET MVC 5 Visual Studio 2013, with the latest nuget libraries.
AngularJS Core 1.3.8
AngularJS UI Bootstrap 0.12.0
Bootstrap 3.3.1
jQuery 2.1.3
Important files:
App.js
var deviceModule = angular.module("devicesModule", ["ui.bootstrap"]);
var app = angular.module("dxuWebApp", ["devicesModule"]);
DeviceController.js
deviceModule.controller("DevicesController", function ($scope, deviceService, $modal) {
$scope.devices = [];
function init() {
$scope.devices = deviceService.getDevices();
}
init();
$scope.addDevice = function(size) {
var modalInstance = $modal.open({
templateUrl: "newDeviceTemplate.html",
controller: "NewDeviceModelController",
size: size
});
modalInstance.opened.then(function() {
alert('yep');
});
modalInstance.result.then(function (newDevice) {
deviceService.postDevice(newDevice);
}, function () {
});
}
});
deviceModule.controller("NewDeviceModelController", function ($scope, $modalInstance) {
$scope.ok = function () {
$modalInstance.close({ name: newDevice.name });
};
$scope.cancel = function () {
$modalInstance.dismiss("cancel");
};
});
newDeviceTemplate.html
<div class="modal-header">
<h2>New Device</h2>
</div>
<div class="modal-body">
<input type="text" data-ng-model="newDevice.name" />
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
Index.cshtml
#{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div data-ng-app="dxuWebApp" data-ng-controller="DevicesController">
<div class="row">
<div class="col-lg-12">
<h2>Devices <a data-ng-click="addDevice()"><span class="glyphicon glyphicon-plus-sign"></span></a></h2>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<ul class="list-inline">
<li data-ng-repeat="device in devices | orderBy: 'name'">
<a href="#">
<div class="device">
<div class="deviceImage">
#*<img alt="device image"/>*#
<span class="glyphicon glyphicon-phone"></span>
</div>
<div class="deviceName">
{{device.name | uppercase}}
</div>
</div>
</a>
</li>
</ul>
</div>
</div>
</div>
#section scripts
{
#Scripts.Render("~/bundles/dxuWebApp")
<script type="text/ng-template" id="newDevice.html">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2>New Device</h2>
</div>
<div class="modal-body">
<input type="text" data-ng-model="newDevice.name" />
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
</div>
</div>
</script>
}
The references to both ui-bootstrap and ui-bootstrap.tpls are in the _layout page.
I was hoping that when I clicked
<a data-ng-click="addDevice()"><span class="glyphicon glyphicon-plus-sign">
AngularJs magic would happen and I would get a modal on the screen, but nothing happens, no errors or anything like that.
I did put a break point on deviceController.addDevice() and it hit that point and goes through, nothing appear on the screen.
So what wrong with my code?
I had the exact same problem.
I am using MVC 5.0 with AngularJS so the reason it wasn't working ( I was getting a 404 not able to find the modal.html.) was I didn't create a route in the controller for the modal.html or map a view to the controller with the same name as the route.
After properly setting up the Controller and the View it worked.
Sorry there is no code for this since it was just a problem following the MVC process.

Resources