Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Probably the best option in the long run would be converting those bootstrap widgets into knockout custom bindings (like e.g. <a href="https://github.com/billpull/knockout-bootstrap" rel="nofollow">https://github.com/billpull/knockout-bootstrap</a>) or even better into native Durandal widgets. </p> <p>Check out how Durandal 1.2 messageBox is implemented. This can be used as a rough guideline to convert bootstrap tabs and dropdowns into Durandal widgets. As you can see <code>href</code> attributes in the view have been replaced by <code>data-bind="click: ..."</code>. In addition you'd have to convert the Bootstrap JavaScript into a Durandal <code>viewmodel</code>.</p> <p>e.g. <a href="http://twitter.github.io/bootstrap/javascript.html#modals" rel="nofollow">http://twitter.github.io/bootstrap/javascript.html#modals</a></p> <pre><code>&lt;div class="modal hide fade"&gt; &lt;div class="modal-header"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria-hidden="true"&gt;&amp;times;&lt;/button&gt; &lt;h3&gt;Modal header&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p&gt;One fine body…&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer"&gt; &lt;a href="#" class="btn"&gt;Close&lt;/a&gt; &lt;a href="#" class="btn btn-primary"&gt;Save changes&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>becomes<br> <a href="https://github.com/dFiddle/dFiddle-1.2/blob/gh-pages/App/durandal/messageBox.html" rel="nofollow">https://github.com/dFiddle/dFiddle-1.2/blob/gh-pages/App/durandal/messageBox.html</a></p> <pre><code>&lt;div class="messageBox"&gt; &lt;div class="modal-header"&gt; &lt;h3 data-bind="html: title"&gt;&lt;/h3&gt; &lt;/div&gt; &lt;div class="modal-body"&gt; &lt;p class="message" data-bind="html: message"&gt;&lt;/p&gt; &lt;/div&gt; &lt;div class="modal-footer" data-bind="foreach: options"&gt; &lt;button class="btn" data-bind="click: function () { $parent.selectOption($data); }, html: $data, css: { 'btn-primary': $index() == 0, autofocus: $index() == 0 }"&gt;&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>Update:</strong> Here's a minimalistic tab widget implementation. Live version at <a href="http://dfiddle.github.io/dFiddle-2.0/#bootstrap" rel="nofollow">http://dfiddle.github.io/dFiddle-2.0/#bootstrap</a> </p> <p><strong>view:</strong></p> <pre><code>&lt;div class="tabs"&gt; &lt;ul class="nav nav-tabs" data-bind="foreach: { data: settings.items }"&gt; &lt;li data-bind="css: {active: isActive}"&gt; &lt;a data-bind="text: name, click: $parent.toggle.bind($parent)"&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;div class="tab-content" data-bind="foreach: { data: settings.items}"&gt; &lt;div class="tab-pane" data-bind="html: content, css: {active: isActive}"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>viewmodel:</strong> </p> <pre><code>define(['durandal/composition', 'jquery'], function(composition, $) { var ctor = function() { }; ctor.prototype.activate = function(settings) { this.settings = settings; }; ctor.prototype.detached = function() { console.log('bootstrap/widget/viewmodel: detached', arguments, this); }; ctor.prototype.toggle = function(model, event){ this.deactivateAll(); model.isActive(true); }; ctor.prototype.deactivateAll = function(){ $.each(this.settings.items(), function(idx, tab){ tab.isActive(false); }); }; return ctor; }); </code></pre>
    singulars
    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.
    1. VO
      singulars
      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