Angular2+ (click) event on radio button not working on Safari/iOS - html

The page is working perfectly in Chrome, IE or Firefox, but in Safari I have a weird problem. The (click) events that are inside the radio buttons are not working, the event is not fired. I have another (click) in a button later and it works fine. The problem happens on iPhone/iMac so is not device related.
The page is nothing more than a survey with some questions. Here is an example of html code:
<div class="col" *ngIf="!valueSelection">
<h4 for="">1.- Question 1</h4>
<div class="form-check">
<input class="form-check-input" type="radio" name="questionRMG1" id="questionRMG1_1" value="answerRMG1_1" [(ngModel)]="valueSelection"
(click)="onSelect(0.25)">
<label class="form-check-label" for="questionRMG1_1">Answer a.</label>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" name="questionRMG1" id="questionRMG1_2" value="answerRMG1_2" [(ngModel)]="valueSelection"
(click)="onSelect(0.10)">
<label class="form-check-label" for="questionRMG1_2">Answer b./label>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" name="questionRMG1" id="questionRMG1_3" value="answerRMG1_3" [(ngModel)]="valueSelection"
(click)="onSelect(0)">
<label class="form-check-label" for="questionRMG1_3">Answer c. </label>
</div>
<br>
<div class="form-check">
<input class="form-check-input" type="radio" name="questionRMG1" id="questionRMG1_4" value="answerRMG1_4" [(ngModel)]="valueSelection"
(click)="onSelect(0,50)">
<label class="form-check-label" for="questionRMG1_4">Answer d. </label>
</div>
<p>
<ngb-progressbar [value]="0" type="info">0%</ngb-progressbar>
</p>
</div>
Here is the code of the (click) that works fine:
<div class="container">
<div class="row">
<div class="col">
<h4>Text</h4>
<br>
<form #mailForm="ngForm">
<div class="form-group">
<label for="exampleInputName1">Name</label>
<input type="text" class="form-control" id="exampleInputName1" [(ngModel)]="inputName" name="inputName" placeholder="nombre empresa">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Mail</label>
<input type="email" class="form-control" id="exampleInputEmail1" [(ngModel)]="inputEmail" name="inputEmail" aria-describedby="emailHelp"
placeholder="mail">
<small id="emailHelp" class="form-text text-muted">Text</small>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1" [(ngModel)]="inputCheck" name="inputCheck">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary" (click)="onSend()" ng-disabled="sending">Enviar</button>
</form>
</div>
</div>
</div>
I really have no idea of what the problem could be.

After more research, i found a similar question: Angular2 radio button not working in Production
I tried changing the environment production variable to false, and now everything works on Safari.
It´s a solution, but i don´t understand why this happens, doesn´t make sense.

Related

I am working on a website with bootstrap4

FORM
I am creating a form like this but i dont know how to place all radio buttons serially in a row. Could someone help me with this.
No. Of Guests
1
<input type="radio" name="opt2" class="form-control" id="opt2">
<label for="opt1">2</label>
<input type="radio" name="opt3" class="form-control" id="opt3">
<label for="opt3">3</label>
<input type="radio" name="opt4" class="form-control" id="opt4">
<label for="opt4">4</label>
<input type="radio" name="opt5" class="form-control" id="opt5">
<label for="opt5">5</label>
</div>
</div>
</form>
This is my code for the radio buttons.When i run this code all buttons are placed vertically.
please don't report this question. I am a noob on this platform so, i dont know exactly how it works.
Thank you in advance.
Use this code :
<div>
<div class="row">
<div class="form-check form-check-inline">
<input name="gruppo2" type="radio" id="radio4" checked>
<label for="radio4">Opzione 1</label>
</div>
<div class="form-check form-check-inline">
<input name="gruppo2" type="radio" id="radio5">
<label for="radio5">Opzione 2</label>
</div>
</div>
</div>
What change? if you use form-check-inline class input radio will display in one row.

Angular Json Pipe TypeError: Converting circular structure to JSON

I have been trying to follow along with an angular course and came across the following error while using ngform:
core.js:6237 ERROR TypeError: Converting circular structure to JSON
--> starting at object with constructor 'TView'
| property 'blueprint' -> object with constructor 'LViewBlueprint'
--- index 1 closes the circle
Following is the template html:
<div class="container">
<h2>User Settings</h2>
<form #form="ngForm">
<div class="form-group">
<label for="name">Name</label>
<input id="name" name="name" class="form-control" placeholder="Name" />
</div>
<div class="form-check form-group">
<input class="form-check-input" type="checkbox" value="" id="emailOffers">
<label class="form-check-label" for="emailOffers">
Email Special Offers
</label>
</div>
<h5>User Interface Style</h5>
<div class="form-group">
<div class="form-check">
<input class="form-check-input" type="radio" name="InterfaceStyle" id="lightInterface" value="Light" checked>
<label class="form-check-label" for="lightInterface">
Light
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="InterfaceStyle" id="mediumInterface" value="Medium">
<label class="form-check-label" for="mediumInterface">
Medium
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="InterfaceStyle" id="darkInterface" value="Dark">
<label class="form-check-label" for="darkInterface">
Dark
</label>
</div>
</div>
<div class="form-group">
<label for="subscriptionType">Subscription Type</label>
<select class="form-control" id="subscriptionType">
<option>Monthly</option>
<option>Annual</option>
<option>Lifetime</option>
</select>
</div>
<div class="form-group">
<label for="notes">Notes</label>
<textarea class="form-control" id="notes" rows="3"></textarea>
</div>
<button class="btn btn-primary">Save</button>
</form>
</div>
{{ form | json }}
It throws you this error because it has some circular dependency on the controls so it throws you this error. You can try out the printing the value of it.
To print the entire formobject you can use
{{form.value | json}}
Stackblitz link => https://stackblitz.com/edit/angular-6-template-driven-form-validation-prcrob

Stacking one jumbotron on top of each other when reducing screen size

I have placed two jumbotrons side-by-side using auto layout columns on Bootstrap 1 of 2, 2 of 2.
When I reduce the size of the page, the two just resize by going thinner and stretching out the content but I want them to stack on top of each other.
How could I do that? I've tried media queries, but maybe I am not selecting the right 'thing' when targeting the jumbotrons to stack. TIA
<div class="container">
<div class="row">
<div class="col">
<div class="jumbotron1 jumbotron-fluid" id="register">
<div class="container1">
<h1 class="display-4">Register your interest!</h1>
<p class="lead">Festival days will be free, but seats will be limited,
so register your interest early and don't miss out!</p>
<form>
<div class="form-group">
<div class="row">
<div class="col">
<label for="firstname">First name</label>
<input type="text" class="form-control" id="firstname"
placeholder="Enter first name">
</div>
<div class="col">
<label for="lastname">Last name</label>
<input type="text" class="form-control" id="lastname"
placeholder="Enter last name">
</div>
</div>
<br>
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="InputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<h4>Which days are you interested in?</h4>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
<label class="form-check-label" for="inlineCheckbox1">August 5th</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
<label class="form-check-label" for="inlineCheckbox2">August 6th</label>
</div>
<br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3">
<label class="form-check-label" for="inlineCheckbox3">August 7th</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3">
<label class="form-check-label" for="inlineCheckbox3">August 8th</label>
</div>
<br>
<br>
<div> <button type="submit" class="btn btn-primary">Submit</button></div>
</form>
</div>
</div>
</div>
<div class="col">
<div class="jumbotron2" id="latestNews">
<h1 class="display-4">Latest News</h1>
<div class="list-group">
</div>
<p class="mb-1"><a class="twitter-timeline" href="https://twitter.com/brooklynfest?ref_src=twsrc%5Etfw" data-tweet-limit="2">Tweets by brooklynfest</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></p>
</a>
</div>
</div>
</div>
Use col-md-6 instead of col
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="jumbotron1 jumbotron-fluid" id="register">
<div class="container1">
<h1 class="display-4">Register your interest!</h1>
<p class="lead">Festival days will be free, but seats will be limited, so register your interest early and don't miss out!</p>
<form>
<div class="form-group">
<div class="row">
<div class="col">
<label for="firstname">First name</label>
<input type="text" class="form-control" id="firstname" placeholder="Enter first name">
</div>
<div class="col">
<label for="lastname">Last name</label>
<input type="text" class="form-control" id="lastname" placeholder="Enter last name">
</div>
</div>
<br>
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="InputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<h4>Which days are you interested in?</h4>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1">
<label class="form-check-label" for="inlineCheckbox1">August 5th</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2">
<label class="form-check-label" for="inlineCheckbox2">August 6th</label>
</div>
<br>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3">
<label class="form-check-label" for="inlineCheckbox3">August 7th</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3">
<label class="form-check-label" for="inlineCheckbox3">August 8th</label>
</div>
<br>
<br>
<div> <button type="submit" class="btn btn-primary">Submit</button></div>
</form>
</div>
</div>
</div>
<div class="col-md-6">
<div class="jumbotron2" id="latestNews">
<h1 class="display-4">Latest News</h1>
<div class="list-group">
</div>
<p class="mb-1"><a class="twitter-timeline" href="https://twitter.com/brooklynfest?ref_src=twsrc%5Etfw" data-tweet-limit="2">Tweets by brooklynfest</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</p>
</div>
</div>
</div>
CodePen
I had the same Problems;
when you use only , the colums will share the place you give them. You can give them also a weight, in bootstrap4 a full row has 12 colms. When u say one col-4 and the other one col-8 then they share the screen like 1/3 and 2/3.
Now You can also give them a size, when they should stop breaking lines. They define the min width of your colm. Like col-sm/md/lg/xl(-1/2/3/4/5/6/7/8/9) e.g. col-md-4.
here stay:
sm for min-width: 576px
md for min-width: 768px
lg for min-width: 992px
xl for min-width: 1200px
I think md should be ok for you. So use col-md to define your colum: div class="col-md"

How to show validation message below horizontal radio buttons in Bootstrap 4.1.3?

I am trying to show validation message below horizontally aligned radio buttons in Bootstrap 4.1.3. Below is the default render:
<hr>
<div class="">
<div class="col-sm text-center">
Please confirm that your eye color is:<br>
<span class="response" id="eye_color"></span>
</div>
<div class="col-sm text-center">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="eye_color_yes" value="yes" name="eye_color" required>
<label class="form-check-label" for="eye_color_yes">Yes</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="eye_color_no" value="no" name="eye_color" required>
<label class="form-check-label" for="eye_color_no">No</label>
<div class="invalid-feedback">
Please select an option.
</div>
</div>
</div>
</div>
<hr>
I tried adding a break <br> and got this:
<hr>
<div class="">
<div class="col-sm text-center">
Please confirm that your eye color is:<br>
<span class="response" id="eye_color"></span>
</div>
<div class="col-sm text-center">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="eye_color_yes" value="yes" name="eye_color" required>
<label class="form-check-label" for="eye_color_yes">Yes</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="eye_color_no" value="no" name="eye_color" required>
<label class="form-check-label" for="eye_color_no">No</label>
<div class="invalid-feedback">
<br>Please select an option.
</div>
</div>
</div>
</div>
<hr>
But what I would really like is for the validation message to appear directly under the two horizontal radio buttons. I am using Bootstrap 4.1.3's validation for ease but for some reason can't figure this part out. Thanks!
I was just struggling with the same thing. This answer is probably too late for you, but hopefully it helps someone else. The validation message is displaying where it is because Bootstrap adds display: inline-flex; on a parent element when displaying horizontal forms, preventing it from dropping down to the next line.
I was able to relocate the invalid-feedback validation message outside the flex layout element, and have it continue to react to the validation (without any extra javascript) by placing a dummy radio button with the same name before it and hiding it with CSS. A bit hacky, but it works.
<div class="col-sm text-center">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="eye_color_yes" value="yes" name="eye_color" required>
<label class="form-check-label" for="eye_color_yes">Yes</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="eye_color_no" value="no" name="eye_color" required>
<label class="form-check-label" for="eye_color_no">No</label>
</div>
<input type="radio" name="eye_color" style="display:none;" required>
<div class="invalid-feedback">
Please select an option.
</div>
</div>
I created a form only using Bootstrap 4 class. You can use this snippet for your desired result.
<div class="container">
<form >
<div class="col-sm-6">
Please confirm that your eye color is:
</div>
<div class="form-check-inline">
<label class="form-check-label" for="radio1">
<input type="radio" class="form-check-input" id="radio1" name="optradio" value="option1" checked>Blue
</label>
</div>
<div class="form-check-inline">
<label class="form-check-label" for="radio2">
<input type="radio" class="form-check-input" id="radio2" name="optradio" value="option2">Black
</label>
</div>
<div class="form-check-inline">
<label class="form-check-label">
<input type="radio" class="form-check-input">Grey
</label>
</div>
<div class="text-danger">
Please select color.
</div>
</form>
</div>
On the place of below code:
<div class="text-danger">
Please select color.
</div>
You can use below snippet it will look better for showing error messages:
<div class="alert alert-danger">
<strong>Warning!</strong> Please select color.
</div>

arrange fields of the form using bootstrap 3?

I am using Bootstrap3 in my project. I have enclosed my form in a jumbotron.
Here is how my form looks (not good looking as of now):
I tried to make it better. but it is getting worse. I want all the fields to be in one-line and
the submit button centered below them. I have no idea how to do it. I am very new using Bootstrap3.
Here is my html code:
<form action="" id="id-exampleForm" class="form-inline" method="post" >
<input type='hidden' name='csrfmiddlewaretoken' value='1bfhNFINdeJVpSNBBQd0X7zLWLVwm1bB' />
<div id="div_id_price_order" class="form-group">
<label for="id_price_order_0" class="control-label col-lg-2 requiredField">
price order
<span class="asteriskField">*</span>
</label>
<div class="controls col-lg-12">
<label class="radio">
<input type="radio" checked="checked" name="price_order" id="id_price_order_1" value="lowest_price" >lowest</label>
<label class="radio">
<input type="radio" name="price_order" id="id_price_order_2" value="highest_price" >highest</label>
</div>
</div>
<div class="form-group">
<div id="div_id_newest_entry" class="checkbox">
<div class="controls col-lg-offset-2 col-lg-12">
<label for="id_newest_entry" class=" requiredField">
<input class="checkboxinput checkbox" id="id_newest_entry" name="newest_entry" type="checkbox" />
latest date
</label>
</div>
</div>
</div>
<div class="form-group">
<div id="div_id_latest_year" class="checkbox">
<div class="controls col-lg-offset-2 col-lg-12">
<label for="id_latest_year" class=" requiredField">
<input class="checkboxinput checkbox" id="id_latest_year" name="latest_year" type="checkbox" />
latest year
</label>
</div>
</div>
</div>
<input type="submit" name="submit" value="Submit" class="btn btn-primary button white" id="submit-id-submit" />
</form>
EDIT:
I want something like this: I have edited this on powerpoint. so it does not look very good.
EDIT AFTER COMMENT
Please see the fiddle for an inline form in a Jumbotron with the button in-line (not below centered), and fieldset.
Note : that I changed the vertical alignment of the checkbox and radio + add some right margin, and an extra small button. The form will go as block if the screen is extra-small as a bootstrap behavior.
JsFiddle
<div class="jumbotron">
<form class="form-inline">
<fieldset class="radiogroup">
<legend>Sorting Criteria</legend>
<label for="id_price_order_0">
price order
<span class="asteriskField">*</span>
</label>
<label class="radio" for="id_price_order_1">
lowest
<input type="radio" checked="checked" id="id_price_order_1" />
</label>
<label class="radio" for="id_price_order_2">
highest
<input type="radio" id="id_price_order_2" />
</label>
<label for="id_newest_entry" class="requiredField checkbox">
latest date
<input id="id_newest_entry" type="checkbox" />
</label>
<label for="id_latest_year" class="requiredField checkbox">
latest year
<input id="id_latest_year" type="checkbox" />
</label>
<input type="submit" name="submit" value="Submit" class="btn btn-primary btn-xs" />
</fieldset>
</form>
Add the class form-control to ALL of your input elements for a start:
<input type="radio" class='form-control' checked="checked" name="price_order" id="id_price_order_1" value="lowest_price" >
Also, what I do to make my life easier is to pre-wrap the elements in the correct sized divs instead of doing it in the labels and inputs like so:
<div class='row'>
<form ... >
<div class='col-lg-2>
<label ... ></label>
<input ... >
</div>
<div class='col-lg-2'>
...
</div>
...
</form>
</div>
Its a tiny bit slower to load but it makes the code so much more readable I think it is worth it. Also I feel that there is a lot of extra in your code that shouldn't be there and is confusing check out the code here: http://getbootstrap.com/css/#forms. They show you exactly how to format an in-line form.
Could being inside a .jumbotron be causing the issues? Why don't you try a panel or a well This should work for you:
<div class='panel panel-default'>
<div class="panel-heading">In-line Form</div>
<div class="panel-body">
<form action='anotherScript.php' method='post' class='form-inline'>
<div class='row'>
<div class='col-md-4'>
<strong>Price:</strong>
<div class="radio-inline">
<label>
<input type="radio" name="rad1" value="low" checked>
Lowest
</label>
</div>
<div class="radio-inline">
<label>
<input type="radio" name="rad1" value="high">
Highest
</label>
</div>
</div>
<div class='col-md-4'>
<div class="checkbox-inline">
<label>
<input type="checkbox" name='date' value='date'>
Latest Date
</label>
</div>
</div>
<div class='col-md-4'>
<div class="checkbox-inline">
<label>
<input type="checkbox" name='year' value='year'>
Latest Year
</label>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<center><button type='submit' class='btn btn-primary'>Submit</button></center></form>
</div>
</div>
</div>
Fiddle: http://jsfiddle.net/52VtD/5046/
Make sure you stretch the results panel to full width to see the form in-line.