Hide Arrow icon in selectize.js - javascript

I'm using the selectize.js package in my application (https://github.com/selectize/selectize.js) and i'm trying to hide the cursor.
Bellow is a code as example:
$('#select-beast-single-disabled').selectize({
create: true,
sortField: {field: 'text'}
});
<html>
<head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.css" />
<div class="demo">
<div class="control-group">
<select id="select-beast-single-disabled" class="demo-default" placeholder="Select a person...">
<option value="">Select a person...</option>
<option value="1">Arnold</option>
<option value="2" selected>Nikola Tesla</option>
</select>
</div>
</div>
</body>
</head>
</html>
Is there any workaround for it? Thank you in advance !

I believe this solves your problem
therefore, two possibilities:
Set the option maxItems with '1' as a string, in order to skip the condition which insert a different css class in the input.
like this:
$('#select-beast-single-disabled').selectize({
create: true,
sortField: {field: 'text'},
maxItems: '1'
});
<html>
<head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.css" />
<div class="demo">
<div class="control-group">
<select id="select-beast-single-disabled" class="demo-default" placeholder="Select a person...">
<option value="">Select a person...</option>
<option value="1">Arnold</option>
<option value="2" selected>Nikola Tesla</option>
</select>
</div>
</div>
</body>
</head>
</html>
Remove the arrow from the css.
like this:
$('#select-beast-single-disabled').selectize({
create: true,
sortField: {field: 'text'}
});
<html>
<head>
<body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.css" />
<div class="demo">
<div class="control-group">
<select id="select-beast-single-disabled" class="demo-default" placeholder="Select a person...">
<option value="">Select a person...</option>
<option value="1">Arnold</option>
<option value="2" selected>Nikola Tesla</option>
</select>
</div>
</div>
<style>
.selectize-control.single .selectize-input:after{
display:none;
}
</style>
</body>
</head>
</html>

Related

select2 js plugin is not working

I just started using select2 jquery plugin . I am trying it on codepan . I added all cdn link (css,js, jquery etc) .But my select items do not change yet . here is my code :
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="UTF-8" />
<title>My New Pen!</title>
<!-- Styles -->
<link rel="stylesheet" href="styles/index.processed.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<div style="width:600px;">
<form action="post">
<select name="" id="myselection">
<option value="dhaka"> Dhaka </option>
<option value="braishal"> Barishal </option>
<option value="Khulna"> Khulna </option>
<option value="rajshahi"> Rajshahi </option>
<option value="dinajpur"> Dinajpur </option>
</select>
</form>
</div>
<!-- Scripts -->
<script src="scripts/index.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myselection').select2();
});
</script>
</body>
</html>
JQuery must be imported before Select2 script for it to work.
So the correct import order should be:
jQuery
Select2
Page specific Javascript
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta -->
<meta charset="UTF-8" />
<title>My New Pen!</title>
<!-- Styles -->
<link rel="stylesheet" href="styles/index.processed.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet" />
</head>
<body>
<div style="width:600px;">
<form action="post">
<select name="" id="myselection">
<option value="dhaka"> Dhaka </option>
<option value="braishal"> Barishal </option>
<option value="Khulna"> Khulna </option>
<option value="rajshahi"> Rajshahi </option>
<option value="dinajpur"> Dinajpur </option>
</select>
</form>
</div>
<!-- Scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/js/select2.min.js">
</script>
<script src="scripts/index.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#myselection').select2();
});
</script>
</body>
</html>

How Create multi select box to create tags

I Want have a multi select box to create tags,I used this code and download select2.min.css and select2.min.js from https://github.com/select2/select2 and copied in css and js file in project,
My code in html file is here:
<link rel="stylesheet"href="https:
//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="
{{asset('css/select2.min.css')}}">
<script type="text/javascript" src="{{asset('js/select2.full.min.js')}}">
</script>
<script type="text/javascript"
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
<script type="text/javascript" src="{{asset('js/select2.min.js')}}">
</script>
<div class="form-group">
<label class="control-label col-sm-2" for="tags">tags:</label>
<select class="form-control select2-multi" name="tags"
multiple="multiple">
#foreach($tags as $tag)
<option value='{{$tag->id}}'>{{$tag->name}}</option>
#endforeach
</select>
</div>
<script>
$('.select2-multi').select2();
</script>
But this Code didn't Work for me,How I Can fixed it?
Image of this code is here:
You need to include jQuery in your project as $ will be undefined. Below is the sample:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/css/select2.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>
<div class="form-group">
<label class="control-label col-sm-2" for="tags">tags:</label>
<select class="form-control select2-multi" name="tags" multiple="multiple">
<option value='tag1'>tag 1</option>
<option value='tag2'>tag 2</option>
<option value='tag3'>tag 3</option>
</select>
</div>
<script>
$('.select2-multi').select2();
</script>
But it will always be a good practice to include your JS code on DOM ready like:
$(function(){
$('.select2-multi').select2();
});

Bootstrap select not working when template that contains select box is included via ng-include

This is my index.html page.
<head>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.min.css">
<link rel="stylesheet" href="css/header.css">
<link rel="stylesheet" href="css/homepage_search_styles.css">
<script src="assets/js/jquery-2.1.0.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="js/controller.js"></script>
<script src="js/quickview.js"></script>
</head>
<body ng-app="myApp">
<div ng-include="'testsearch.html'"></div>
</body>
This is testsearch.html
<div ng-controller="exampleController">
<div>
Blah blah blah
</div>
<select name="model" id="model" class="selectpicker" data-live-search="true" multiple ng-model="sel" title="Any">
<option data-tokens="Restaurant">Restaurant </option>
<option data-tokens="Vegetarian">Vegetarian</option>
<option data-tokens="Bar">Bar</option>
<option data-tokens="Night Life">Night Life</option>
<option data-tokens="Breakfast">Breakfast</option>
<option data-tokens="Fast Food">Fast Food</option>
</select>
<div> Blah blah blah</div>
</div>
All the other components except the select box appears when I run index.html.
Also, if I include the testsearch.html template directly in the index.html, selectbox appears.
Can somebody tell me why does it behave that way?

How to disable submit button until drop down value selected

<!DOCTYPE html>
<html ng-app>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script type="text/javascript" src="upf.js"></script>
</head>
<body>
<div align="center" style="width: 100%;">
<div align="center" style="border-color: black; border-style: solid; width: 800px;">
<h2 align="center">UPF PD DATA ENTRY!</h2>
<p>
<form id="myform" action="" method="post">
<fieldset>
<div ng-controller="IndustryCntrl">
Industry:
<select id="industry" ng-model="segments" ng-options="industry for (industry, segments) in Industries">
<option value=''>Select</option>
</select>
Segment:
<select id="segment" ng-disabled="!segments" ng-model="margins" ng-options="segment for (segment,margin) in segments">
<option value=''>Select</option>
</select>
margin:
<select id="margin" id="showhide_form" ng-disabled="!margins || !segments" ng-model="margin">
<option value=''>Select</option>
<option ng-repeat="margin in margins" value='{{margin}}'>{{margin}}</option>
</select>
</div>
</fieldset>
</form>
</div>
</div>
</body>
</html>
I want disable submit button until drop-down value selected,by using jQuery or JavaScript.
Using Jquery you can do it liike the below code:
$('#submitorder').attr('disabled', 'disabled');
function updateFormEnabled() {
if (verifyAdSettings()) {
$('#submitorder').attr('disabled', '');
} else {
$('#submitorder').attr('disabled', 'disabled');
}
}
function verifyAdSettings() {
if ($('#ad_duration').val() != '' && $('#ad_type').val() != '') {
return true;
} else {
return false
}
}
$('#ad_duration').change(updateFormEnabled);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<form id="ad_form" method="post" action="">
<p>
<label for="ad_type" class="labelStrong">Advertising Type</label>
</p>
<p>
<select id="ad_duration" name="ad_duration">
<option value="" selected="selected">Select premium ad duration</option>
<option value="weekly">Weekly</option>
<option value="fortnightly">Fortnightly</option>
<option value="monthly">Monthy</option>
</select>
<label for="ad_duration" class="labelStrong">Advertising Duration</label>
</p>
<p>
<div id="calender">
</div>
</p>
<p>
<input type="submit" name="submit" value="Submit" id="submitorder" />
</p>
</form>

jqtransform dynamic select option?

i am using jqtransform plugin to create select input, i make some change in js file i am creating a select option instead of li and i create a differente script to get select option innerhtml but when i calling this function on window.onload function is working for not working second time.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="gmapkey" content="" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<title></title>
<link rel="stylesheet" href="jqtransformplugin/jqtransform.css" type="text/css" media="all" />
<link rel="stylesheet" href="demo.css" type="text/css" media="all" />
<script type="text/javascript" src="requiered/jquery.js" ></script>
<script type="text/javascript" src="jqtransformplugin/jquery.jqtransform.js" ></script>
<script language="javascript">
$(function(){
$('form').jqTransform({imgPath:'jqtransformplugin/img/'});
});
</script>
<script type="text/javascript">
function change () {
var jAm= document.getElementById('sltnew');
var jM= jAm.options[jAm.selectedIndex].text;
document.getElementById('catch').innerHTML=jM;
}
document.ajay.sltnew.onchange=change;
</script>
</head>
<body>
<form action="post.php" method="POST" name="ajay">
<div class="rowElem"><label>Input Text:</label><input type="text" name="inputtext"/></div>
<div class="rowElem"><label>Input Password:</label><input type="password" /></div>
<div class="rowElem"><label>Checkbox: </label><input type="checkbox" name="chbox" id=""></div>
<div class="rowElem"><label>Radio :</label>
<input type="radio" id="" name="question" value="oui" checked ><label>oui</label>
<input type="radio" id="" name="question" value="non" ><label>non</label></div>
<div class="rowElem"><label>Textarea :</label> <textarea cols="40" rows="12" name="mytext"></textarea></div>
<div class="rowElem">
<label>Select :</label>
<select name="select">
<option value="">1</option>
<option value="opt1"></option>
</select>
</div>
<div class="rowElem" style="float:left; width:500px; position:relative">
<label>Select Redimentionné :</label>
<select name="sltnew" id="sltnew" onchange="change ()">
<option value="opt1">Select states</option>
<option value="opt2">Option 2</option>
<option value="opt3">Option 3</option>
<option value="opt4">Option 4</option>
<option value="opt5">Option 5</option>
<option value="opt6">Option 6</option>
<option value="opt7">Option 7</option>
<option value="opt8">Option 8</option>
</select>
<div id="catch">select city</div>
</div>
<div class="rowElem"><label>Submit button:</label><input type="submit" value="Envoyer" /></div>
<div class="rowElem"><label>Reset button:</label><input type="reset" value="Annuler" /></div>
<div class="rowElem"><label>Input button:</label><input type="button" value="bouton" /></div>
</form>
</body>
</html>
change in jqtransform file what i made.
$wrapper.prepend('<div><span></span></div><select id="slt"></select>');
var $ul = $('select', $wrapper).css('width',$select.width()).hide();
/* Now we add the options */
$('option', this).each(function(i){
var oLi = $('<option>'+ $(this).html() +'</option>');
$ul.append(oLi);
});
just try this
http://www.pkoretic.net/csTransPie

Categories