Skip to content

Commit cf4f35c

Browse files
committed
Merge branch 'master' of https://github.com/ddsky/unibox
2 parents f8e862d + 4c8aa1e commit cf4f35c

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ For suggestions to work you have two parts. First, the unibox.min.js and unibox.
3030
```
3131

3232
```javascript
33-
// create a settings object
34-
var settings = {
33+
34+
$("#searchBox").unibox({
3535
// these are required:
3636
suggestUrl: '', // the URL that provides the data for the suggest
3737
// these are optional:
@@ -53,10 +53,7 @@ var settings = {
5353
blurCallback: undefined, // callback on blur events on the search box
5454
minChars: 3, // minimum number of characters before the suggests shows, default: 3
5555
maxWidth: 400 // the maximum width of the suggest box, default: as wide as the input box
56-
};
57-
58-
// apply the settings to an input that should get the unibox
59-
$("#searchBox").unibox(settings);
56+
});
6057
```
6158

6259
### Server Side
@@ -87,3 +84,26 @@ The field `suggests` contains search suggests grouped under headlines. For examp
8784
The field `words` is for the instant visual feedback. All the words or phrases that you recognized should be entered here so they can be shown to the user.
8885

8986
That's it already. If you use unibox and want to let me know, I include your usage example here. Happy coding.
87+
88+
### Notes to keep in mind
89+
#### Multi UniBoxes
90+
If you want to initialize more that 1 UniBox in the same page you can wrap the initialization function in an event that triggers when the user switches between input boxes , such as focus
91+
```javascript
92+
$(".usernameBox").focus(function(){
93+
$(".usernameBox").unibox({
94+
suggestUrl: ' path to your server-side', // the URL that provides the data for the suggest
95+
});
96+
$(".emailBox").focus(function(){
97+
$(".emailBox").unibox({
98+
suggestUrl: ' path to your server-side', // the URL that provides the data for the suggest
99+
});
100+
```
101+
#### Bootstrap Fixes
102+
If you are willing to use bootstrap along with Unibox keep in mind that unibox will mess your `input-group-addon`'s height,
103+
use this css to fix it
104+
```css
105+
#unibox-invisible{
106+
position: absolute!important;
107+
/*important for fixing the input-group-addon heights*/
108+
}
109+
```

0 commit comments

Comments
 (0)