jquery mobile data-native-menu with data-history attribute - jquery-mobile

<div data-role="fieldcontain">
<select data-mini="true" data-inline="false" data-history="false" data-native-menu="false" data-theme="d" data-overlay-theme="b" name="elArr[]">
<option value="" data-placeholder="true">test</option>
<option value="1">1</option>
</select>
</div>
Hi, I like use data-native-menu with data-histroy attribute same time. data-history property doesn't work. When opened native menu, it add hash ui-state=dialog to location bar.

Related

Select2 and Thymeleaf integration

I created a simple search bar with multiple options enabled by the Select2 library:
<form th:action="#{/searchuser}" method="post">
<div th:object="${searchInput}">
<div class="input-group mb-3">
<input type="text" th:field="*{key}" class="form-control form-control-lg" placeholder="Search Here">
<div class="input-group-prepend">
<span class="input-group-text" type="submit"><i class="fas fa-search"></i></span>
</div>
</div>
<select class="select2-multiple-choices select2-choice" multiple="multiple" th:field="*{parameters}">
<option th:value="'id'" value="id"> Id</option>
<option th:value="'First Name'" value="First Name"> First
Name</option>
<option th:value="'Middle Name'"> Middle Name</option>
<option th:value="'Last Name'" value="Last Name"> Last Name</option>
<option th:value="'mail'" value="Mail"> E-Mail </option>
</select>
</div>
</div>
The controller:
#RequestMapping(value = "/searchuser", method = RequestMethod.POST)
public ModelAndView searchUser(Locale locale,
#ModelAttribute("searchInput") SearchUserDTO searchdto,
BindingResult searchBindResult,
Model model) {....}
SearchUserDTO contains String key and List parameters.
I would sent to server the search key and the selected options. How can I get the selection and pass them with thymeleaf?

SOLVED - Select2 attr "selected" stop working when set false

The goal is to select users according to the option chosen in the first select.
It works fine the first time you select that type of user. But when I change the user type and go back to the previous one, it doesn't show the options in the select. But through the inspect element it appears that the option has the "selected" attribute
<label for="UserType" class="col-md-2 control-label">User Type nbsp;<span class="text-danger small">*</span></label> <div class="col-md-4">
<select class="select2_demo_1 form-control" id="UserType" name="UserType">
<option value='0' selected disabled hidden>-- Selecionar --</option>
<option value="1">Boss</option>
<option value="2">Admin</option>
<option value="3">User</option>
</select>
<label for="Users" class="col-md-2 control-label">Users <span class="text-danger small">*</span></label><div class="col-md-10">
<select id="Users" name="Users" class="select2_demo_1 form-control" multiple style="width:100%">
<option data-type='1' value="1" >User Boss</option>
<option data-type='2' value="2" >User Admin</option>
<option data-type='2' value="3" >User Admin 2</option>
<option data-type='3' value="4" >User</option>
</select>
$('#UserType').on('change', function() {
var UserType = $(this).val();
$("select#Users option:selected").attr("selected",false);
$("select#Users option[data-type="+ UserType +"]").attr("selected","selected");
$("#Users").select2();
});
$('#UserType').trigger('change');
------ Solution ------
Change the code segment
$("select#Users option:selected").attr("selected",false);
$("select#Users option[data-type="+ UserType +"]").attr("selected","selected");
$("#Users").select2();
by the following
$('#UserType').select2('destroy').find('option').prop('selected', false).end().select2();
$('#UserType').select2('destroy').find('option[data-type='+ UserType+']').prop('selected', 'selected').end().select2();
You may think to add selected="true" and then change it to false when you apply the function attr()

Rails mechanize gem - scraping

I want to fill in some options which trigger the downloading of a file, using the Mechanize gem.
The HTML is the following.
<div>
<form action="" id="label_selectors" method="post">
...
...
<div class="source form_options">
<select name="source" id="source">
<option value="btce" selected="selected">Btc-e</option>
<option value="cryptsy">Cryptsy</option>
<option value="796">796</option>
<option value="bitstamp">Bitstamp</option>
<option value="formulas">Altcoin Indexes</option>
</select>
</div>
<div class="label form_options">
<select name="label" id="label">
</select>
</div>
<div class="period form_options">
<select name="period" id="period">
<option value="15m">15 minute</option>
<option value="1h" selected="selected">1 hour</option>
<option value="1d">1 day</option>
</select>
</div>
<div class="presense form_options">
CSV: <input type="radio" name="presence" value="csv"> Chart: <input type="radio" name="presence" value="chart" checked="checked">
</div>
<div class="submit form_options">
<input type="submit" name="submit" value="OK">
</div>
</form>
</div>
I tried to do something like this:
form = page.forms.first
form.source = "btce"
form.label = "BTC/USD"
form.period = "1d"
form.presense = "csv"
form.submit
However, it doesn't work:
NoMethodError: undefined method `presense=' for #<Mechanize::Form:0x007fb878dc7f98
(the typo presense rather than presence appears in the page)
How could I fill in this form correctly?
It looks like the presence input is a radio button.
To select a radio button with mechanize you'll want something like:
form.radiobuttons_with(name: 'presence')[0].check
There's other ways to select radio buttons with mechanize - you can see them here: http://docs.seattlerb.org/mechanize/GUIDE_rdoc.html

jQuery Mobile- data-theme="d" is not working

I want to use data-theme d in my select. How ever jQuery Mobile ignores the data-theme="d"and display it as theme a.
<div id="mutualFriends">
<select class="sortBy" name="sortBy" data-url="${url}" data-theme="d">
<option value="">Sort By</option>
<option value="new" selected="selected">Newest</option>
<option value="old">Oldest</option>
<option value="firstName_asc">First Name a-z</option>
</select>

DropDownList automatically closes in Firefox

I have several forms in ASP.Net MVC.
I noticed that some of the dropdowns close automatically in FireFox, but not in IE.
I don't have any Javascript or JQuery with triggered actions on any of these dropdowns.
Any ideas on why this is happening?
<form action="Index" id="MyID" method="get"><label>
Search <input id="searchWord" name="searchWord" type="text" value="" />
Category <select id="CategoryID" name="CategoryID"><option value="">-- Select All --</option>
<option value="1">Item A</option>
<option value="2">Item B</option>
<option value="3">Item C</option>
<option value="4">Item D</option>
<option value="5">Item E</option>
</select>
</label>
<label>
<input class="button" value="Search" type="submit" />
</label>
</form>
The dropdown list is coded using Razor as:
#Html.DropDownList("CategoryID", "-- Select All --")
The <label> tag defines a label. You have wrong close tag for <label>.

Resources