jQuery Mobile - Disable multiple select menu label changes - count bubble - jquery-mobile

When using a selection menu with the option for multiple select, jquery changes the menu's label based on the selected elements.
http://jquerymobile.com/demos/1.1.0/docs/forms/selects/custom.html
See this fiddle. When user selects shipping options, the selected elements show in the menu's label.
http://jsfiddle.net/VEYjV/3/
How can I disable this feature and force the menu to keep the label I've associated with it (i.e. Choose options)? How can I disable the count bubble feature?

I figured out how to disable these features by hacking into the jquery.mobile lib.
I disabled the setButtonText and setButtonCount funcions when called from the refresh
refresh: function() {
//this.setButtonText();
//this.setButtonCount();
},

Related

Vaadin Accordion with Button in summary

In my Vaadin 14 app, I want to add an Accordion component that has several components in its summary (which is always displayed), among which a Button. Clicking in the summary normally toggles the display of the AccordionPanel content. How can I prevent the AccordionPanel to collapse/expand when the button in the summary is clicked?
Objects are created simply as follows:
Accordion accordion = new Accordion();
MyPanel panel = new MyPanel();
accordion.add(panel);
with MyPanel constructor simply calling setSummary() with a layout containing the button.
I found the answer in this thread on the forum.
It turns out you can prevent the propagation of the button click with this hack:
button.getElement().addEventListener("click", click -> {
//do nothing
}).addEventData("event.stopPropagation()");
This seems like a core functionality that the framework should provide out of the box, but this ticket is still open.
Adding this to your view:
UI.getCurrent().getPage()
.executeJs("Array.from(document.getElementsByTagName('vaadin-accordion-panel')).forEach(element=>element.shadowRoot.querySelector(\"div[role=button]\").replaceWith(element.shadowRoot.querySelector(\"div[role=button]\").cloneNode(true)))");
will disable all clicks on all the accordions toggle and accordion summary. However you will need to include a button or trigger for opening and closing the accordion. I don't know if this is what you want?

Select2 drop-down list is not repositioned to show added tags

I'm using Select2 (version 4.0.2) to allow users to select multiple values and make tags of them. The problem is that when the span holding the tags is expanded after new tags are selected, the drop-down values list area is not repositioned accordingly.
This figure shows the Select2 area containing several previously selected values, prior to selecting additional values:
This figure shows what happens after I select one or more choices, which are hidden because the tags area is taller than it was, but the drop-down options list is stuck in the same position:
If I take focus from (blur) the tag area, the drop-down is re-displayed in the proper position to show all of the currently selected values/tags:
Question
How do I get the drop-down options area to dynamically reposition as new tag values are selected? Can I intercept a Select2 event and somehow force it to recalculate the vertical position? Or perhaps blur() then focus() the span each time a selection is chosen?
The solution I came up with was to force the drop-down element to be resized whenever a drop-down choice was selected or de-selected, which required catching the "change" event:
// Apply Select2 to the <select> element
var select2Elem = $("#" + controlID).select2(opts);
// Force drop-down list to resize upon select/unselect
select2Elem.on("change",
function(evt) {
select2Elem.resize();
}
);

Select2 change container position

How can I adjust the position of Select2 container so that the search box is position right over the original select element like in this website
http://www.jobnisit.com/en
It look cleaner in terms of UI in my opinion.
Ps. sorry, I can't post the image now.
There is 2 ways to do this.
1) With css:
.select2-dropdown--below {
top: -2.8rem; /*your input height*/
}
This will not affect a container (.select2-container), but will move dropdown and search field, so you will have a desired effect.
2) With js:
$('select').select2().on('select2:open', function() {
var container = .$('.select2-container').last();
/*Add some css-class to container or reposition it*/
});
This code attaches a handler to 'select2:open' event, which will be fired every time when user opens a dropdown. This method is better if you have more than one select on page.
Tested with select2 4.0.0
The proper way of positioning the dropdown is using the core feature provided by select2 plugin.
It provides us with 'dropdownParent' property to place to dropdown inside the particular element
select field: #edit-field-job-skillsets-tid
parent item: div.form-item-field-job-skillsets-tid
jQuery("#edit-field-job-skillsets-tid").select2(
{dropdownParent: jQuery('div.form-item-field-job-skillsets-tid')}
);

jquerymobile - selectable list item

I want to be able to select a listview item. On select/click I can use onclick event and add class to that li. But, is there any default way in which I can select an item in the listview. I mean, when I select, it should be highlighted and I should be able to get the selected value.
The jQM listview widget does not include any default functionality for a highlighted/selected item. Your approach of
handling the click,
adding a class, and
storing the currently
selected item in a global or data-attribute
is a good way to go.

Enable/Disable sortable on specify column in kendo ui grid

I have a kendo ui grid on my page.
And I have a button too. I want when I click button, sortable property on a specify column disable, and when click the button again, sortable property enable.
How to I do this?
Thanks.
Runtime enabling/disabling the sorting feature of the Grid is not supported.
But you can find some approaches to achieve it here: http://www.telerik.com/forums/disable-or-remove-sortable-capability-on-column-with-rebuilding-entire-grid
Hope this link will help you.
There is no method for this - this is option which is set only upon initialziation. So you will need to re-initialize the whole Grid. Covered here.
The column.sortable option should be set to true/false depending on the button that was clicked.
You need to write an click event for a table header on javascript.This event will prevent click on table header.
$(".k-grid-header .k-link").click(function (e) {
e.preventDefault();
if ($(this).text() === Header Name) {
e.stopPropagation();
}
});
e.PreventDefault helps to avoid window jump to top when clicking #-links.
Give your headername into the if condition to which you want to disable sorting

Resources