Code Monkey home page Code Monkey logo

Comments (5)

truckingsim avatar truckingsim commented on June 16, 2024

@rougin for now:

The reason add to FormField works is that your calling selectpicker on the new form. You'll need to do the same thing here for ajaxSelectPicker:

 function addformfield() {
        counter += 1;
        var packing = $('#packing');
        var originalSelect = packing.find('select');
        var clone = packing.clone();
        clone.appendTo('#product_field');
        clone.attr('id', 'packing_' + counter);
        clone.find('.bootstrap-select').remove();
        clone.find('select').selectpicker();

        clone.find('select').ajaxSelectPicker(originalSelect.data().ajaxSelectPicker.ajaxOptions);
    }

That should work, it will take the options that you passed to original ajaxSelectPicker call and pass it on the clone. There isn't really a way around this unfortunately as internally cached data (which jQuery uses when you use .data()) is not cloned on .clone.

Let me know if that doesn't work and I'll take a deeper look.

from ajax-bootstrap-select.

rougin avatar rougin commented on June 16, 2024

@truckingsim thanks for the quick response! It runs as I expected. Thank you very much! 👯

from ajax-bootstrap-select.

velbur avatar velbur commented on June 16, 2024

Please help, same issue. Made everything but error appear:
Uncaught TypeError: Cannot read property 'ajaxOptions' of undefined

from ajax-bootstrap-select.

markhalliwell avatar markhalliwell commented on June 16, 2024

Please read jQuery's documentation on how $.fn.clone works.

from ajax-bootstrap-select.

velbur avatar velbur commented on June 16, 2024

Maybe i need replace ajaxOptions something else?

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.