Comments (6)
Ugly as f*uck
`
var
var selected = { value: value, title: title };
$abs.val(selected.value).trigger('change').selectpicker('refresh');
$abs.data('AjaxBootstrapSelect').list.setTitle(selected.title);
$abs.data('AjaxBootstrapSelect').list.refresh();
`
from ajax-bootstrap-select.
I'm using this for clear button might help.
$(document).on('click', '#ajax-student-clear', function(){
$("#ajax-select-students").val('').trigger('change');
})
from ajax-bootstrap-select.
I am also interested in this answer, its the final piece of my form I need to resolve.
from ajax-bootstrap-select.
@PoetikDragon here is what I ended up using I did a lot of digging in the inspect element to figure this out:
// Terrible hack to set the default data.
// Todo: NEED TO CHANGE THIS! UNCLEAN
var $productAssociationInput = $(".product-associated");
var $currentProductAssociated = $productAssociationInput.val();
if($currentProductAssociated != "") {
$(".product_associated_div").find(".bootstrap-select").find("button").remove();
$(".product_associated_div").find(".bootstrap-select").prepend('<button type="button" class="btn dropdown-toggle selectpicker btn-default" data-toggle="dropdown" data-id="product_associated" title="'+$currentProductAssociated+'"><span class="filter-option pull-left">'+$currentProductAssociated+'</span> <span class="caret"></span></button>');
}
in "currentProductAssociated" you put the default data that you want in the select, the .product_associated_div is just a div around the bootstrap select so I can navigate through the elements.
Let me know if this works for you
from ajax-bootstrap-select.
Might be cleaner solution:
$("#oib").empty();
$("#oib").append("<option value='test'>Test</option>");
$("#oib").selectpicker("refresh");
from ajax-bootstrap-select.
I have the same issue and looking for a solution around documentation and StackOverflow, but I'm not lucky enough to get solution except for this close ISSUE.
I have tried @ganaited solution but I'm not clear about the options variable of his solution. kindly apologize for my JS knowledge
from ajax-bootstrap-select.
Related Issues (20)
- reset/clear previous search result HOT 1
- ajax-bootstrap-select breaks required field HOT 1
- with-ajax makes changed.bs.select event to be called on search, not on change HOT 10
- New release - update of dist files
- How to hide locale.statusInitialized field?
- No results event HOT 1
- Trigger options when initialization HOT 1
- Post not not reach the server
- Attempting to destroy selectpicker and reinitialize ajaxselect creates standard select HOT 2
- Cancel the previous request if another one has been sent. HOT 1
- multiple + preserveSelected + default <options> groups unselected options into 'Currently Selected' HOT 2
- Selecting an empty option doesn't seem possible
- Add sort for selectpicker
- not working correctly in mobile
- Search Filtering
- Add support for HTML attributs "data-xxx" on custom content
- Return in HTML (Retorno em HTML)
- In Bootstrap 5.2.3 Ajax-Bootstrap-Select doesn't work HOT 8
- Select text content as you type (Selecionar o conteúdo do texto enquanto digita) HOT 1
- Make the function dynamic (Deixar a função dinâmica) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ajax-bootstrap-select.