hola amigos
tengo este codigo dentro del body
Código HTML:
Ver original <div class='liveExample'>
<form data-bind="submit:addItem"> Add item:
<input type="text" data-bind='value:itemToAdd, valueUpdate: "afterkeydown"' /> <button type="submit" data-bind="enable: itemToAdd().length > 0">Add
</button>
<select multiple="multiple" height="5" data-bind="options:allItems, selectedOptions:selectedItems"> </select>
<button data-bind="click: removeSelected, enable: selectedItems().length > 0">Remove
</button> <button data-bind="click: sortItems, enable: allItems().length > 1">Sort
</button>
<script type='text/javascript'>//
<![CDATA[
var BetterListModel = function () {
this.itemToAdd = ko.observable("");
this.allItems = ko.observableArray(["Fries", "Eggs Benedict", "Ham", "Cheese"]); // Initial items
this.selectedItems = ko.observableArray(["Ham"]); // Initial selection
this.addItem = function () {
if ((this.itemToAdd() != "") && (this.allItems.indexOf(this.itemToAdd()) < 0)) // Prevent blanks and duplicates
this.allItems.push(this.itemToAdd());
this.itemToAdd(""); // Clear the text box
};
this.removeSelected = function () {
this.allItems.removeAll(this.selectedItems());
this.selectedItems([]); // Clear selection
};
this.sortItems = function() {
this.allItems.sort();
};
};
ko.applyBindings(new BetterListModel());
//]]>
mi consulta es:
como puedo sacar el js en un archivo aparte y llamarlo por medio de src
sin que afecte el funcionamiento, ya que
itemToAdd
es un termino comun dentro de los div como del script
gracias