Is there a way to convert twitter bootstrap's typeahead function into a $("body").on() function? The following code works fine if the element exists on the page load.
$("#job_title").typeahead({
    source: searchFunction,        
    onselect: function(obj) {            
    }
});
But if I add the text input with id="job_title" dynamically, the above function doesn't work.  Is there a workaround for this?
This solution requires no additional javascript. From https://stackoverflow.com/a/15094730
$("#element-that-will-contain-typeaheads").on("DOMNodeInserted", function () {
    $(this).find(".typeahead").typeahead();
});
                        I downloaded jquery.livequery.js to get the behavior I wanted:
$("#job_title").livequery("create", function() {
    $(this).typeahead({
        source: searchFunction,        
        onselect: function(obj) {            
        }
    });
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With