Giter VIP home page Giter VIP logo

Comments (6)

ganaited avatar ganaited commented on July 17, 2024 3

Ugly as f*uck

`
var $abs = $('select').selectpicker(options).ajaxSelectPicker(options);
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.

fdobrovolny avatar fdobrovolny commented on July 17, 2024

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.

PoetikDragon avatar PoetikDragon commented on July 17, 2024

I am also interested in this answer, its the final piece of my form I need to resolve.

from ajax-bootstrap-select.

bvisonl avatar bvisonl commented on July 17, 2024

@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>&nbsp;<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.

alexGDdev avatar alexGDdev commented on July 17, 2024

Might be cleaner solution:

$("#oib").empty();
$("#oib").append("<option value='test'>Test</option>");
$("#oib").selectpicker("refresh");

from ajax-bootstrap-select.

dduleep avatar dduleep commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.