Note that there are some explanatory texts on larger screens.

plurals
  1. POBootstrap typeahead inside Durandal SPA application
    primarykey
    data
    text
    <p>I have a SPA application using the default durandal package set-up. I am using Knockout, Jquery, Jquery ui, and trying to use the twitter bootstrap typeahead. I building on the default durandal pages using this html on my shell.html(navbar)</p> <pre><code>&lt;form class="navbar-search pull-right"&gt; &lt;input type="text" class="search-query" id="employeeSearch" placeholder="Search Employees" data-bind="typeahead: employees"&gt; &lt;/form&gt; </code></pre> <p>In order to use the typeahead as a custom knockout binding I am using the answers provided here <a href="https://stackoverflow.com/questions/16195200/creating-a-autocomplete-field-with-typeahead-in-the-durandal-framework/16355062#16355062">Creating a autocomplete field with Typeahead in the Durandal Framework</a></p> <p>I am creating my own datasource in my connected js file here</p> <pre><code>this.employees = function () { var self = this; $.ajax(app.url('/employees'), { contentType: 'application/json', dataType: 'jsonp', success: function (result) { self.employees = result; } }); }; var shell = { router: router, employees: employees, activate: function () { return boot(); } }; return shell; </code></pre> <p>I am using Nancy on the backend to create a webservice so that is the reason for using jsonp as my dataType. I am able to get my results back fine, however when loading the page, i keep getting an error "Object [object Object] has no method 'typeahead'" in chrome debugger where the page never finishes loading. </p> <p>Also, when I remove the knockout-bootstrap library, the page is able to load without any errors, but the search box is non functional. I have also made sure that I am including all my libraries in the right order, jQuery->jQueryUI->knockout->bootstrap->custom javascript. Most of all the examples I have seen work, but I cannot wrap my head around this problem!</p> <p>Most of the examples I have seen use this content in their js </p> <pre><code>$('#employeeSearch').typeahead({ source: function (query, process) { return $.get(window.location.pathname +'?ajax=accounts&amp;ajax_mode=search', { 'value': query }, function (data) { return process(data.result); }); }, minLength: 1, items: 12 }); //A rough example </code></pre> <p>I have tried using this method but have not been able to within the SPA framework. Let me know any thoughts or is more code is needed. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload