milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

applyBindings

Details
Written by: Stanko Milosev
Category: Knockout
Published: 01 October 2013
Last Updated: 01 October 2013
Hits: 4663

When we want to apply bindings on the particular element using jquery, we should use following code:

ko.applyBindings(new CarsViewModel(), $('#form0')[0]);

Zero ([0]) is important, otherwise it will not work.

Closing tags

Details
Written by: Stanko Milosev
Category: Knockout
Published: 01 October 2013
Last Updated: 01 October 2013
Hits: 4241

It seems that knockout doesn't like HTML without closing tags. Code like:

<div data-bind="foreach: Cars">

	<!-- car value has to exist and has to be under quotes, otherwise it doesn't work -->
	<select autowidth="true" data-bind="
		options: $root.carTypes
		,optionsValue: 'carValue'
	"/>
	<br>test</br>

</div>

Will produce something like (notice that "test" is inside select tag):

<select autowidth="true" data-bind="
				options: $root.carTypes
				,optionsValue: 'carValue'
			"><option value="BMW">BMW</option><option value="Ferrari">Ferrari</option><option value="Fiat">Fiat</option><option value="Ford">Ford</option><option value="Mercedes-Benz">Mercedes-Benz</option>
			test

		

	

</select>

Code like:

<div data-bind="foreach: Cars">

	<!-- car value has to exist and has to be under quotes, otherwise it doesn't work -->
	<select autowidth="true" data-bind="
		options: $root.carTypes
		,optionsValue: 'carValue'
	"></select>
	<br></br>

</div>

Will produce something like:

<div data-bind="foreach: Cars">

	<!-- car value has to exist and has to be under quotes, otherwise it doesn't work -->
	<select autowidth="true" data-bind="
		options: $root.carTypes
		,optionsValue: 'carValue'
	"><option value="BMW">BMW</option><option value="Ferrari">Ferrari</option><option value="Fiat">Fiat</option><option value="Ford">Ford</option><option value="Mercedes-Benz">Mercedes-Benz</option></select>
	<br><br>

</div>

Notice <br> tag two times

Finally code (notice that br is without closing tag):

<div data-bind="foreach: Cars">

	<!-- car value has to exist and has to be under quotes, otherwise it doesn't work -->
	<select autowidth="true" data-bind="
		options: $root.carTypes
		,optionsValue: 'carValue'
	"></select>
	<br/>

</div>

Will work as expected

self = this

Details
Written by: Stanko Milosev
Category: Knockout
Published: 01 October 2013
Last Updated: 30 November -0001
Hits: 4584

Because this can be something else, read here.

Autocomplete

Details
Written by: Stanko Milosev
Category: Knockout
Published: 30 September 2013
Last Updated: 30 September 2013
Hits: 4579

Example is taken from here. And my example you can see here. As usual my example is ugly :), without CSS but idea is just to see an example.

  1. Change the value of drop down list
  2. Few examples
  3. Testing private callbacks
  4. callFake

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 72 of 168

  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76