Polymer 2.0, property access - data-binding

I have quite simple component that does a login with username/password. The template has a button which calls the "login()" method. The console shows for username/password both undefined. I tried everything but nothing works. What am I'm doing wrong?
<template>
<style>
:host {
display: block;
}
</style>
<h2>Hello [[prop1]], authenticated=[[authenticated]]!</h2>
<div>
<div><label>Username: </label><input value="{{username::input}}"></input></div>
<div><label>Password: </label><input type="password" value="{{password::input}}"></input></div>
<div>
<button onclick="{{logIn}}" raised>Log in</button>
</div>
</div>
</template>
Here is the login method:
logIn() {
console.log("username="+this.username+", password="+this.password);
}

Maybe paper-input fixes your Problem
<template>
<style>
:host {
display: block;
}
</style>
<h2>Hello [[prop1]], authenticated=[[authenticated]]!</h2>
<div>
<div><label>Username: </label><paper-input id="usn" value="{{username}}"></input></div>
<div><label>Password: </label><paper-input id="pwd" type="password" value="{{password}}"></input></div>
<div>
<button onclick="[[logIn]]" raised>Log in</button>
</div>
</div>
</template>
On the other hand you could try changing you logIn method to this should also work with just an input don´t forget to set an id:
logIn() {
console.log("username="+this.$.usn.value+", password="+this.$.pwd.value);
}

Related

ERROR TypeError: Cannot read properties of null (reading 'classList') in styles.css

So, I am trying to add background color change to my navbar when the scrollY goes more than 30px, and it works though. But I'm getting this error on my console as it is not able to add the new classList to the header when it goes over 30px.
This is my .ts file
ngOnInit(): void {
function scrollHeader(){
const nav = document.getElementById('header');
if(window.scrollY >= 30){
nav.classList.add('scroll-header');
}else{
nav.classList.remove('scroll-header');
}
}
window.addEventListener('scroll', scrollHeader);
}
this is the style file:
.scroll-header{
background: #242526;
color: white;
}
.scroll-header .wrapper .logo a{
color:white;
}
This is the HTML File:
<nav id="header">
<div class="wrapper">
<div class="logo">
<a [routerLink]="'/'">InsuranceBazaar</a>
</div>
<input type="radio" name="slider" id="menu-btn">
<input type="radio" name="slider" id="close-btn">
<ul class="nav-links">
<label for="close-btn" class="btn close-btn">
<i class="fa fa-times"></i>
</label>
<li>
....
I don't know what the error is, but I guess it is because of ngOnInit(). Please if anyone knows how to solve this error do share the answer.
Is your function correctly called ?
Maybe you should try without ngOnInit().
Then try to check the scroll with console.log()?
Or maybe try more specifically #header.scroll-header then your style ...

CSS check box problem should select when Ill checked it

I created a check box into a div and I created a label.I want that when Ill click to check box(#check_box) that time it (#pop_hidden)will be hidden{display: none}. no problem if I use javascript. I just need a solution
#check_box[type=checkbox]:checked : #pop_hidden {
display: none;
}
<div>
<input type="checkbox" id="check_box">
</div>
<div>
<label id="pop_hidden">CSS is Awesome</label>
</div>
Its Working if I use
<!DOCTYPE html>
<html>
<head>
<style>
#checkbox[type=checkbox]:checked + #pop_hidden {
display:none;
}
</style>
</head>
<body>
<input type="checkbox" id="checkbox" name="ossm">
<label id="pop_hidden">CSS is Awesome</label>
</body>
</html>
but I want to use it into the div like the first example
I supppose you are looking for that...
const
checkBox = document.querySelector('#check_box')
, popHiden = document.querySelector('#pop_hidden')
;
checkBox.oninput = e =>
{
popHiden.classList.toggle('noDisplay', checkBox.checked)
}
.noDisplay {
display: none;
}
<div>
<input type="checkbox" id="check_box">
</div>
<div>
<label id="pop_hidden">CSS is Awesome</label>
<br>
other content in div
</div>

Meteor Stripe Elements not rendering

Am attempting to use Stripe elements form (v3) with a meteor form. All code runs without blowing up but nothing is rendered after mount() is called. Any ideas?
js:
Template.billing.onRendered(function(){
let elements = stripe.elements();
let style = {
base: {
// Add your base input styles here. For example:
fontSize: '16px',
color: "#32325d",
}
};
let card = elements.create('card', {style: style});
card.mount('#card-element');
console.log("done");
})
html:
<template name="billing">
<form id="payment-form">
<div class="form-row">
<label for="card-element">
Credit or debit card
</label>
<div id="card-element">
</div>
<div id="card-errors" role="alert"></div>
</div>
<input type="submit" class="submit" value="Submit Payment">
</form>
</template>
Nevermind, it was actually rendering but the width was 0 for some reason, so messing around with the css works.

How to make hashtag links work on Internet Explorer?

This tutorial teaches how to create modal windows in CSS3. It works perfectly on Chrome and Firefox. However, Internet Explorer doesn't load any of the links containing hashtags.
Tutorial
Demo
The first link has the source code but I'll post a copy below for future reference.
HTML
<html lang="en" >
<head>
<meta charset="utf-8" />
<title>CSS3 Modal Popups | Script Tutorials</title>
<link href="css/layout.css" rel="stylesheet" type="text/css" />
<link href="css/modal.css" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<h2>CSS3 Modal Popups</h2>
Back to original tutorial on <span>Script Tutorials</span>
</header>
<!-- panel with buttons -->
<div class="main">
<div class="panel">
Log In
Sign Up
</div>
</div>
<!-- popup form #1 -->
<div class="popup">
<h2>Welcome Guest!</h2>
<p>Please enter your login and password here</p>
<div>
<label for="login">Login</label>
<input type="text" id="login" value="" />
</div>
<div>
<label for="password">Password</label>
<input type="password" id="password" value="" />
</div>
<input type="button" value="Log In" />
<a class="close" href="#close"></a>
</div>
<!-- popup form #2 -->
<div class="popup">
<h2>Sign Up</h2>
<p>Please enter your details here</p>
<div>
<label for="email">Login (Email)</label>
<input type="text" id="email" value="" />
</div>
<div>
<label for="pass">Password</label>
<input type="password" id="pass" value="" />
</div>
<div>
<label for="firstname">First name</label>
<input type="text" id="firstname" value="" />
</div>
<div>
<label for="lastname">Last name</label>
<input type="text" id="lastname" value="" />
</div>
<input type="button" value="Sign Up" /> or Log In
<a class="close" href="#close"></a>
</div>
</body>
</html>
CSS
.main {
    background: #aaa url(../images/bg.jpg) no-repeat;
    width: 800px;
    height: 600px;
    margin: 50px auto;
}
.panel {
    background-color: #444;
    height: 34px;
    padding: 10px;
}
.panel a#login_pop, .panel a#join_pop {
    border: 2px solid #aaa;
    color: #fff;
    display: block;
    float: right;
    margin-right: 10px;
    padding: 5px 10px;
    text-decoration: none;
    text-shadow: 1px 1px #000;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    -ms-border-radius: 10px;
    -o-border-radius: 10px;
    border-radius: 10px;
}
a#login_pop:hover, a#join_pop:hover {
    border-color: #eee;
}
.overlay {
    background-color: rgba(0, 0, 0, 0.6);
    bottom: 0;
    cursor: default;
    left: 0;
    opacity: 0;
    position: fixed;
    right: 0;
    top: 0;
    visibility: hidden;
    z-index: 1;
    -webkit-transition: opacity .5s;
    -moz-transition: opacity .5s;
    -ms-transition: opacity .5s;
    -o-transition: opacity .5s;
    transition: opacity .5s;
}
.overlay:target {
    visibility: visible;
    opacity: 1;
}
.popup {
    background-color: #fff;
    border: 3px solid #fff;
    display: inline-block;
    left: 50%;
    opacity: 0;
    padding: 15px;
    position: fixed;
    text-align: justify;
    top: 40%;
    visibility: hidden;
    z-index: 10;
    -webkit-transform: translate(-50%, -50%);
    -moz-transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    -o-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    -ms-border-radius: 10px;
    -o-border-radius: 10px;
    border-radius: 10px;
    -webkit-box-shadow: 0 1px 1px 2px rgba(0, 0, 0, 0.4) inset;
    -moz-box-shadow: 0 1px 1px 2px rgba(0, 0, 0, 0.4) inset;
    -ms-box-shadow: 0 1px 1px 2px rgba(0, 0, 0, 0.4) inset;
    -o-box-shadow: 0 1px 1px 2px rgba(0, 0, 0, 0.4) inset;
    box-shadow: 0 1px 1px 2px rgba(0, 0, 0, 0.4) inset;
    -webkit-transition: opacity .5s, top .5s;
    -moz-transition: opacity .5s, top .5s;
    -ms-transition: opacity .5s, top .5s;
    -o-transition: opacity .5s, top .5s;
    transition: opacity .5s, top .5s;
}
.overlay:target+.popup {
    top: 50%;
    opacity: 1;
    visibility: visible;
}
.close {
    background-color: rgba(0, 0, 0, 0.8);
    height: 30px;
    line-height: 30px;
    position: absolute;
    right: 0;
    text-align: center;
    text-decoration: none;
    top: -15px;
    width: 30px;
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    -ms-border-radius: 15px;
    -o-border-radius: 15px;
    border-radius: 15px;
}
.close:before {
    color: rgba(255, 255, 255, 0.9);
    content: "X";
    font-size: 24px;
    text-shadow: 0 -1px rgba(0, 0, 0, 0.9);
}
.close:hover {
    background-color: rgba(64, 128, 128, 0.8);
}
.popup p, .popup div {
    margin-bottom: 10px;
}
.popup label {
    display: inline-block;
    text-align: left;
    width: 120px;
}
.popup input[type="text"], .popup input[type="password"] {
    border: 1px solid;
    border-color: #999 #ccc #ccc;
    margin: 0;
    padding: 2px;
    -webkit-border-radius: 2px;
    -moz-border-radius: 2px;
    -ms-border-radius: 2px;
    -o-border-radius: 2px;
    border-radius: 2px;
}
.popup input[type="text"]:hover, .popup input[type="password"]:hover {
    border-color: #555 #888 #888;
}
I've run into this problem before with hashchange events in internet explorer, so I wrote this code (Guaranteed by me down to IE7):
Add class hash-modifier to every element that you have that modifies
the url hash.
JavaScript:
$(function () {
var hashchangeHandler = function () {
switch (location.hash.replace(/^.*#/, '')) {
case 'sign-up':
alert('signing up/opening sign-up modal');
break;
case 'login':
alert('logging in/showing login modal');
break;
default:
// do default something
}
}
BindHashChangeEventListener(hashchangeHandler);
// Run the initial hashHandler function on document ready
hashchangeHandler();
});
function BindHashChangeEventListener(hashHandler) {
if (("onhashchange" in window) && !($.browser.msie)) {
// Use built-in jQuery hashchange event
$(window).bind('hashchange', hashHandler);
} else {
//IE and browsers that don't support hashchange
$('.hash-modifier').on('click', function () {
setTimeout(hashHandler, 50);
});
}
}
HTML:
sign up
login

couldn't use error style of twitter bootsrap

I want to use the "input with error" styling
as appear here:
http://twitter.github.com/bootstrap/
and after it a custom css only
(relevant row is 722
form .clearfix.error > label, form .clearfix.error .help-block, form .clearfix.error .help-inline {
color: #b94a48;
}
)
My markup:
<div id="new_folder_name_div" class="clearfix error">
<label for="new_folder_name">Name&nbsp</label>
<div class="input">
<input class="medium error" id="folder_name" size="15" type="text" />
<span>*</span>
</div>
An image:
but I see with Chrome console the input element isn't matched with the above css role.
Any idea why ?
The actual input is the next line down. Note that the containing div with classes "clearfix error" is required.
form .clearfix.error input, form .clearfix.error textarea {
color: #B94A48;
border-color: #EE5F5B;
}
<div class="clearfix error">
<div class="input">
<input class="xlarge error" type="text">
</div>
</div>
Try using
$('#folder_name').closest('.clearfix error').addClass('error');

Resources