javascript - KnockoutJS data-bind optionsCaption -
var vm = { weatherid: ko.observable(), weatherconditions: [{ id: '1', name: 'sunny' }, { id: '2', name: 'rainy' }, { id: '3', name: 'cloudy' }, { id: '4', name: 'snowy' }] }; ko.applybindings(vm);
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script> <select data-bind="options: weatherconditions, value: weatherid, optionstext:'name', optionscaption: 'select today weather'"> </select>
i have ko data bind snippet want set optionscaption
read "select today's weather". wasn't able inset apostrophe in middle - need help.
escape apostrophe backslash \
optionscaption: 'select today\'s weather'">
var vm = { weatherid: ko.observable(), weatherconditions: [{ id: '1', name: 'sunny' }, { id: '2', name: 'rainy' }, { id: '3', name: 'cloudy' }, { id: '4', name: 'snowy' }] }; ko.applybindings(vm);
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-min.js"></script> <select data-bind="options: weatherconditions, value: weatherid, optionstext:'name', optionscaption: 'select today\'s weather'"> </select>
Comments
Post a Comment