You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-6Lines changed: 26 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,8 +30,8 @@ For suggestions to work you have two parts. First, the unibox.min.js and unibox.
30
30
```
31
31
32
32
```javascript
33
-
// create a settings object
34
-
var settings ={
33
+
34
+
$("#searchBox").unibox({
35
35
// these are required:
36
36
suggestUrl:'', // the URL that provides the data for the suggest
37
37
// these are optional:
@@ -53,10 +53,7 @@ var settings = {
53
53
blurCallback:undefined, // callback on blur events on the search box
54
54
minChars:3, // minimum number of characters before the suggests shows, default: 3
55
55
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
+
});
60
57
```
61
58
62
59
### Server Side
@@ -87,3 +84,26 @@ The field `suggests` contains search suggests grouped under headlines. For examp
87
84
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.
88
85
89
86
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*/
0 commit comments