twitter-typeahead not autocompleting or selecting - twitter-typeahead

Getting some weird behaviour with Twitter typeahead. It correctly fetches the data and displays a drowndown list after 3 characters are input, but it does NOT autocomplete the field, nor highlight/select the item. What have I done wrong?
I have the following javascript (after all the relevant jquery and typeahead stuff):
$(function ()
{
var customers = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/api/customers?query=%QUERY',
wildcard: '%QUERY'
}
});
$('#customer').typeahead
(
{
minLength: 3,
highlight: true
},
{
name: 'customers',
display: 'name',
source: customers
}
);
});
relevant part of the webpage
<form>
<div class="form-group">
<label>Customer</label>
<input id="customer" type="text" value="" class="form-control" />
</div>
<div class="form-group">
<label>Movie</label>
<input id="movie" type="text" value="" class="form-control" />
</div>
<button class="btn btn-primary">Submit</button>
</form>
And the css:
.typeahead {
background-color: #fff;
}
.typeahead:focus {
border: 2px solid #0097cf;
}
.tt-query {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.tt-hint {
color: #999
}
.tt-menu {
width: 422px;
margin: 12px 0;
padding: 8px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0, 0, 0, 0.2);
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
box-shadow: 0 5px 10px rgba(0,0,0,.2);
}
.tt-suggestion {
padding: 3px 20px;
font-size: 18px;
line-height: 24px;
}
.tt-suggestion:hover {
cursor: pointer;
color: #fff;
background-color: #0097cf;
}
.tt-suggestion.tt-cursor {
color: #fff;
background-color: #0097cf;
}
.tt-suggestion p {
margin: 0;
}
It seems to get rendered out as:
<input id="customer" type="text" value="" class="form-control tt-input" autocomplete="off" spellcheck="false" dir="auto" style="position: relative; vertical-align: top; background-color: transparent;">
Which is interesting, as it says
autocomplete="off"
but changing that doesn't help...

It turns out that my controller was returning an IHttpActionResult rather than the IEnumerable<Customer> that I was expecting. I don't KNOW if that was the issue, but now that I have fixed that, it works..

Related

Pseudo class in CSS

I'm currently working on a footer. There are 3 input-elements as you can see in the picture. Now, if you click on a input, the border-top becomes white. And now I want to achieve: if a input-field is filled with text and I click on another element, a green border-top has to appear. Which pseudo class do I have to use?
HTML:
<div id="footer">
<ul>
<li> <input type="text" name="name" placeholder="Name"> </li>
<li> <input type="text" name="email" placeholder="Email"> </li>
<li> <input class="last" type="text" name="message" placeholder="Message"> </li>
</ul>
</div>
CSS:
#footer {
width: 100%;
background-color: rgba(0, 0, 0, 0.8);
text-align: center;
padding: 20px 0px;
}
input {
padding: 10px 5%;
background: rgba(0, 0, 0, 0.4);
outline: none;
width: 60%;
margin-bottom: 30px;
font-family: Roboto-Thin;
color: white;
border: none;
border-bottom: 2px solid rgba(255, 255, 255, 0.0);
border-top: 2px solid rgba(255, 255, 255, 0.0);
font-size: 18px;
transition: 0.2s;
}
.last {
margin-bottom: 0px;
}
input:focus {
border-top: 2px solid white;
}
[1]: https://i.stack.imgur.com/4ZE0K.png
Since you're using placeholders, you can use :not(:placeholder-shown):not(:focus)
#footer {
width: 100%;
background-color: rgba(0, 0, 0, 0.8);
text-align: center;
padding: 20px 0px;
}
input {
padding: 10px 5%;
background: rgba(0, 0, 0, 0.4);
outline: none;
width: 60%;
margin-bottom: 30px;
font-family: Roboto-Thin;
color: white;
border: none;
border-bottom: 2px solid rgba(255, 255, 255, 0.0);
border-top: 2px solid rgba(255, 255, 255, 0.0);
font-size: 18px;
transition: 0.2s;
}
.last {
margin-bottom: 0px;
}
input:focus {
border-top: 2px solid white;
}
input:not(:placeholder-shown):not(:focus) {
border-top: 1px solid green;
}
<div id="footer">
<ul>
<li> <input type="text" name="name" placeholder="Name"> </li>
<li> <input type="text" name="email" placeholder="Email"> </li>
<li> <input class="last" type="text" name="message" placeholder="Message"> </li>
</ul>
</div>

How to put inputs into other input

I have two inputs, first is type="text" and second one is type="submit". I'm trying to show the button one inside first input.
.inputs {
width: 245px;
padding: 15px 25px;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 400;
font-size: 14px;
color: #9D9E9E;
text-shadow: 1px 1px 0 rgba(256, 256, 256, 1.0);
background: #FFF;
border: 1px solid #FFF;
border-radius: 5px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
}
<form>
<input type="email" class="inputs" placeholder="Enter your e-mail" name="email" required="required" />
<input type="submit" value="subscribe" id="subbutton" />
</form>
This is what I want to create
You could achieve this by positioning the icon and the button absolutely and giving them appropriate styles.
form {
display: inline-block;
padding: 0;
margin: 0;
position: relative;
}
.inputs {
width: 245px;
padding: 15px 82px 15px 50px;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 400;
font-size: 14px;
color: #9D9E9E;
text-shadow: 1px 1px 0 rgba(256, 256, 256, 1.0);
background: #FFF;
border: 1px solid #FFF;
border-radius: 5px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
}
#subbutton {
position: absolute;
background:#EEE;
border:none;
font-size:1em;
color: #3C3B39;
right: 0;
bottom: 2px;
width: auto;
font-size: 13px;
height: calc(100% - 4px);
box-sizing: border-box;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
cursor: pointer;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
}
#subbutton:hover {
background: #C4C4C4;
}
input:focus {
outline: 0;
}
#subbutton::-moz-focus-inner {
border: 0;
}
#envelope {
position: absolute;
width: 50px;
height: 100%;
line-height: 50px;
text-align: center;
font-size: 40px;
background: url(http://3.bp.blogspot.com/-LjFGCzX54lw/VMP2MYfNh2I/AAAAAAAAAF4/5lfFXmCwIjk/s1600/Screenshot_1.png) no-repeat;
background-position: 5px 10px;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<form>
<div id="envelope"></div>
<input type="email" class="inputs" placeholder="Enter your e-mail" name="email" required="required" />
<input type="submit" value="Subscribe" id="subbutton" />
</form>
.inputs {
width: 245px;
padding: 15px 25px;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 400;
font-size: 14px;
color: #9D9E9E;
text-shadow: 1px 1px 0 rgba(256, 256, 256, 1.0);
background: #FFF;
border: 1px solid grey;
border-radius: 5px 0 0 5px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
/* background */
background-image: url(http://3.bp.blogspot.com/-LjFGCzX54lw/VMP2MYfNh2I/AAAAAAAAAF4/5lfFXmCwIjk/s1600/Screenshot_1.png);
background-repeat: no-repeat;
background-position: right
}
input[type=submit] {
border-radius: 0 5px 5px 0;
background: white;
border: solid 1px grey;
padding: 14px 25px;
border-left: none
}
<form>
<input type="email" class="inputs" placeholder="Enter your e-mail" name="email" required="required" /><!--
--><input type="submit" value="subscribe" id="subbutton" />
</form>
#input{
width:260px;
border:1px solid #ccc;
overflow:auto;
height:50px;
border-radius:5px;
}
input.input{
float:left;
margin:0px 5px 0px 0px;
}
input#inp1{
border:0px;
width:150px;
padding:15px 0px 15px 2px;
font-size:1em;
}
input#inp2{
border:0px;
border-right:1px solid #ccc;
width:50px;
font-size:1em;
color:#667;
background:#fff;
padding:16px 0px 16px 0px;
}
img.input{
padding:6px 0px 0px 0px;
}
<form>
<div id="input">
<input id="inp2" class="input" type="submit" name="" value="GO!">
<input id="inp1" class="input" type="email" name="" value="" placeholder="Enter Email Here" required="required">
<img class="input" src="http://3.bp.blogspot.com/-LjFGCzX54lw/VMP2MYfNh2I/AAAAAAAAAF4/5lfFXmCwIjk/s1600/Screenshot_1.png" width="46px">
</div>
</form>

HTML to PDF - How to display checkbox using itext XMLWorker

I am trying to display checkbox using XML worker but unable to do so. I have also tried through CSS but still not able to display the same when converting HTML to PDF. I am using "itextpdf-5.4.2.jar" and "xmlworker-5.4.1.jar". Request you to please help me with an alternative solution other than YaHP Converter because i already completed 90% of my coding. Thanks in advance !!!!
Following is the sample HTML code which i have tried:
<HTML>
<HEAD>
<script>
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
margin-bottom: 10px;
}
label:before {
content:"";
display: inline-block;
width: 16px;
height: 16px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #aaa;
box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
border-radius: 3px;
}
input[type=checkbox] {
content:"\2713";
text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
font-size: 15px;
color: #f3f3f3;
text-align: center;
line-height: 15px;
}
input[type=checkbox]:checked + label:before {
content:"\2713";
text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
font-size: 15px;
color: #f3f3f3;
text-align: center;
line-height: 15px;
}
</script>
</HEAD>
<BODY>
<div class="checkbox">
<input id="check1" type="checkbox" name="check" value="check1" CHECKED/>
<label for="check1">Checkbox No. 1</label>
<br/>
<input id="check2" type="checkbox" name="check" value="check2"/>
<label for="check2">Checkbox No. 2</label>
<br/>
<input id="check3" type="checkbox" name="check" value="check3" checked/>
<label for="check3">Checkbox No. 3</label>
</div>
</BODY>
</HTML>
Following is the output in PDF:
Checkbox No. 1
Checkbox No. 2
Checkbox No. 3
Check this question in stackoverflow.HTML to PDF using iText : How can produce a checkbox
using the Unicode '&#x2610' character you can create.

How to add a triangle to the right of the labels using css?

I want to add a little triangle to the right to overlap with the beginning of the input field but I haven't been able to. Here's my code:
HTML:
<div id="wrapper">
<form>
<label>First Name</label><input type="text" name="firstname" id="first" placeholder="Jorge" />
<label>Last Name</label><input type="text" name="lastname" id="last" placeholder="González" />
<label>Email</label> <input type="email" name="username" id="un" placeholder="jgon#gmail.com"/>
<label>Password</label> <input type="password" name="password" id="pass" placeholder="********" />
<input type="submit" value="Sign up" id="submit" />
</form>
</div>​
CSS:
html{background-color:#000;}
label{
font-weight: bold;
background: -webkit-linear-gradient(#3073BF 0%, #204C7F 100%);
padding: .7em .85em .8em 0em;
display: block;
width: 100px;
float: left;
border-radius: .3em 0px 0px .3em;
margin: 5px 0;
color: #102640;
text-shadow: 0px 1px 1px #fff;/*rgba(0, 0, 0, 0.3);*/
height: 17px;
}
#wrapper{
width: 800px;
margin: 3em auto;
background: white;
padding: 2em 4em;
border-radius: .5em;
box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.3);
}
form{
width: 330px;
margin: 0 auto;
text-align: right;
}
input{
padding: .5em;
border-radius: 0px 4px 4px 0px;
border: 1px solid #bcbcbc;
margin: .3em 0;
font-size: 1.1em;
}
#submit{
text-align: center;
clear: both;
float: none;
position: relative;
right:10px;
margin: 1em;
padding: 1em 3em;
background: -webkit-linear-gradient(#fff1ba 0%, #ffc400 100%);
border: 1px solid #ffb135;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
font-weight: bolder;
color: #a74f00;
font-size: 1em;
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.7);
cursor: pointer;
border-radius: .3em;
width:300px;
}
#submit:hover{
background: -webkit-linear-gradient(#ffc400 0%, #fff1ba 100%);
}​
and the link to the fiddle: http://jsfiddle.net/Luis_Armando/HeDVy/
To create a triangle you can use following css. Add to your code as required.
.triangle{
width: 0px;
height: 0px;
border-style: solid;
border-width: 30px 0 30px 20px;
border-color: transparent transparent transparent #007bff;
}
Change border-width parameters to change size of triangle.

How do I float 3 elements right above each other and one left?

I want to align the 3 input elements on the right, above each other. And the textarea on the left. Just like this: http://cl.ly/Gvzo
How do I make it work?
<div id="contact">
<form action="php/contact/contactengine.php" method="post">
<fieldset>
<input id="Name" name="Name" placeholder="Enter your full name" type="text">
<input id="Email" name="Email" placeholder="Enter your email address" type="email">
<input type="submit" name="submit" value="Send your message">
<textarea id="message" name="Message" placeholder="What's on your mind?"></textarea>
</fieldset>
</form>
</div>
My CSS:
contact {
width: 670px;
}
input {
float:right;
width: 251px;
height: 50px;
padding: 0px 20px 0px 20px;
margin: 0 0 20px 0;
background: #fcfcfc;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border:1px solid #d6d6d6;
box-shadow:inset 0 0 4px #d6d6d6;
-moz-box-shadow-inset: inset 0 0 4px #d6d6d6;
-webkit-box-shadow: inset 0 0 4px #d6d6d6;
font-size: 13px;
font-weight:bold;
color: #2a2a2a;
}
textarea {
float:left;
width: 251px;
height: 170px;
padding: 12px 20px 12px 20px;
margin: 0px;
background: #fcfcfc;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border:1px solid #d6d6d6;
box-shadow:inset 0 0 4px #d6d6d6;
-moz-box-shadow-inset: inset 0 0 4px #d6d6d6;
-webkit-box-shadow: inset 0 0 4px #d6d6d6;
font-size: 13px;
font-weight:bold;
color: #2a2a2a;
resize:none;
}
input[type=submit] {
float:right;
border:none;
font-size:16px;
width: 293px; height: 51px;
float: right;
padding: 7px 20px 10px 10px;
margin:0px;
background: url(../../img/contactsendbutton.png) no-repeat;
cursor: pointer;
color:#fff;
text-shadow:1px 1px 1px #000;
}
I edited this answer because it wasn't entirely accurate.
First of all, the way you identify a div by its ID in CSS is by placing a '#'-character in front of it.
The order in which you place your elements is relevant when using float. When you first create the elements on the right, they are placed next to eachother, starting from the right, until it doesn't fit. In this case (since the left textarea hasn't been created) it stops when it reaches the other side of the div that contains it.
If you create the left textarea first, the right floating elements can't be placed next to each other, so they will be placed underneath each other.
You always have to keep in mind the margin, width and the width of its parent.
In code it should be a little like this:
HTML:
<div id="contact">
<form action="php/contact/contactengine.php" method="post">
<fieldset>
<textarea id="message" name="Message" placeholder="What's on your mind?"></textarea>
<input id="Name" name="Name" placeholder="Enter your full name" type="text">
<input id="Email" name="Email" placeholder="Enter your email address" type="email">
<input type="submit" name="submit" value="Send your message">
</fieldset>
</form>
</div>
CSS:
#contact {
width: 670px;
}
input {
float:right;
width: 251px;
height: 50px;
padding: 0px 20px 0px 20px;
margin: 10px;
background: #fcfcfc;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border:1px solid #d6d6d6;
box-shadow:inset 0 0 4px #d6d6d6;
-moz-box-shadow-inset: inset 0 0 4px #d6d6d6;
-webkit-box-shadow: inset 0 0 4px #d6d6d6;
font-size: 13px;
font-weight:bold;
color: #2a2a2a;
}
textarea {
float:left;
width: 251px;
height: 170px;
padding: 12px 0px 12px 20px;
margin: 10px;
background: #fcfcfc;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border:1px solid #d6d6d6;
box-shadow:inset 0 0 4px #d6d6d6;
-moz-box-shadow-inset: inset 0 0 4px #d6d6d6;
-webkit-box-shadow: inset 0 0 4px #d6d6d6;
font-size: 13px;
font-weight:bold;
color: #2a2a2a;
resize:none;
}
input[type=submit] {
float:right;
border:none;
font-size:16px;
width: 251px; height: 50px;
float: right;
padding: 7px 20px 10px 10px;
margin:10px;
background: url(../../img/contactsendbutton.png) no-repeat;
cursor: pointer;
color:#fff;
text-shadow:1px 1px 1px #000;
}

Resources