jQuery UI Autocomplete Width issue - jquery-ui

please see this http://jsfiddle.[net]/Nkkzg/108/ (SO doesn't allow to like to JsFiddle) and write 'Apple' in auto-complete text box. You can see a long string appears and with that page's horizontal scroll bar also appear which is very annoying.
I want to show the full string as a result without setting the width, You can see autocomplete results div shows from the left corner to maximum right depending on string length. How can we show the results in the center of page like input textbox, so that horizontal scroll bar shouldn't appear.
Any help will be highly appreciated.
Thanks and Regards.

According to this article:
jQuery UI Autocomplete Width Not Set Correctly
It looks as though you need to place everything in a container and specify the appendTo property telling it where to put the menu.

You should try to use position:absolute
.ui-autocomplete {
max-height: 200px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
border:1px solid #222;
position:absolute;
}
Live Demo

You could try to put this in your .css file
span input.ui-autocomplete-input {
width: 100%;
}
In that way the autocomplete get's the width you have style it to according to the styleClass that is on the enclosing span tag

Related

Xpages NamePicker dialog alignment and width

<xe:namePicker id="npUserNames" for="hdnUserNames">
<xe:this.dataProvider>
<xe:dominoViewNamePicker viewName="Techs"></xe:dominoViewNamePicker>
</xe:this.dataProvider>
</xe:namePicker>
The Names in the left box of the dialog are center aligned. Same with the right (selected values) box.
I have tried text-align: left css in every possible surrounding element...The table cell, the table it is in, the surrounding div tag, the panel, the layout, the entire xpage. And the content of the namepicker dialog is still centered. How do I fix that? How can I specify the width of the dialog box?
Also, in IE11, the "X" button does not work. Nothing happens when you click it.
I'd recommend interrogating the HTML generated using your browser's developer tools to see if there's a class defined for the relevant HTML tags that you can override. If so, you can use that. If not, you may need to create your own Renderer or extension of the Name Picker to generate different HTML. That will be more complicated, but the trade-off of any framework is limited configurability at the cost of quicker development.
I'm not doing exactly what Withers suggested, but it did lead me to a solution based on a comment somewhere else.
I added a class dojo attribute and assigned a new css class to it. Only issue is that it is shifting everything in the dialog to the left...but it's ok for now.
<xe:this.dojoAttributes>
<xp:dojoAttribute name="class" value="namePickerClass">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
CSS:
.namePickerClass { margin: 0 auto; width: 50%; text-align:left; border: 1px solid blue; scrolling: none;
}

Vaadin label content too big

I have this piece of code
private VaadinLabel email,
this.email = new VaadinLabel();
this.informativoDab = new VaadinLabel();
HorizontalLayout row = new HorizontalLayout();
row.setWidth("100%");
row.addComponent(this.email);
row.addComponent(this.informativoDab);
And it gives me this:
When I actually want this:
It should be simple to do, but I've tried doing
this.email.setWidth("50%");
and it didn't work.
How can I do this with Vaadin Label, since I also need a hint to show the entire e-mail?
You should actually use "100%" as the label size as it should take all the space the layout gives for it, half in this case.
By default Vaadin will then wrapt the text on multiple lines. IIRC there isn't a built in css style name to do it, so you'll need to use CSS to disable wrapping and use the ellipsis to visualise overflown text. You could e.g. use "cut_text" style name (email.addStyleName("cut_text")) for your email label along with following css rules to your theme:
.cut_text {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
as #mstahv mentioned, add a style name to your label
email.addStyleName("cut_text");
and use that css he wrote
.cut_text {
white-space: nowrap;
text-overflow: ellipsis;
}
as for the whole email to be displayed, I would suggest adding a description. Then when user hovers the hidden email it will popup in a small tooltip.
email.setDescription("very_long#email.com");

Vaadin OptionGroup caption location

I am trying to get an OptionGroup to have the labels next to them, on the right hand side like normal radio buttons in every other UI I have ever used, instead of underneath them. I do not see anything in the API regarding how to change the layout of this? Anyone point me in the correct direction?
Follow these steps:
Add these lines to your css
.v-select-optiongroup-horizontal .v-select-option {
display: inline-block;
}
.v-select-optiongroup-horizontal {
white-space: nowrap;
}
.v-select-optiongroup-horizontal
.v-select-option.v-radiobutton {
padding-right: 10px;
}
And call
group.setStyleName("horizontal");
where group is the OptionGroup object.
Is it possible that you inherited some styles that display the text like that?
Did you try to call hzl.setSizeUndefined()? Or maybe playing with the width (setWidth()).

jQuery UI selectable and scrollbar

I have a div with divs inside. The outer one has overflow-y: auto;, so with many internal items the right scrollbar appears. After doing $('#container').selectable(); when I press left mouse button over the scrollbar, it doesn't scroll, but a dotted frame for selecting is shown.
I have found this solution: JQuery UI Selectable plugin: Make scroll bar not selectable when div overflows
Unfortunately, it doesn't work for me, because when I scroll to the bottom, the items stop being selectable. (Though the top ones continue). So, the question is: how make the scrollbar... mmm... a scrolling bar, without splitting the container into 2 divs.
Well, it seems to be all browsers problem: when you click on a scrollbar, a mouse event is fired. This is the real problem, jQuery UI just doesn't solve it. Let's fix it on our own in the jQuery UI .js file (not applied to the min version as it should be obfuscated AFAIK).
Add this condition
if (event.pageX > $(event.target)[0].clientWidth + $(event.target).offset().left)
return;
right after the
_mouseDown: function(event) {
I have seen a lot of such hacks with HasScrollbar() detectors, but don't get why didn't they just sum up client width (that is without scrollbar) and offset to make it relative to the document and compare with pageX. For me it works perfectly.
Use a wrapper div for this , Its working fine for me.
.selectable-wrapper { border-radius: 5px; min-height: 200px; max-height: 200px; overflow-y: auto; border: 1px solid #D1D1D1;}
.selectable { list-style-type: none;padding: 5px;}
<div class="selectable-wrapper">
<ul class="selectable">
</ul>
</div>

jQuery autocomplete list position change

I would like to move position a bit to the left of my jQuery UI suggestion list. Here function and everything work very fine
Unfortunately I have no idea how to move that list a bit to left align left about 10px the page is responsive that is why scared that how to move left.
I think this is the documentation: http://docs.jquery.com/Plugins/Autocomplete/autocomplete.
You can set the style in this class
.ui-menu .ui-menu-item a.ui-state-hover, .ui-menu .ui-menu-item a.ui-state-active
{
margin-left: -10px !important;
}
Try adding this in your CSS and not in the jQuery-ui CSS file
you can add margin-left: -11px; in to the list DIV

Resources