This binding is used to generate a unique name for a DOM element. If the DOM element did not have a name attribute, this binding gives it one and sets it to some unique string value.
You won’t need to use this often. It’s only useful in a few rare cases, for example −
jQuery Validation currently will only validate elements that have names. To use this with a Knockout UI, it’s sometimes necessary to apply the uniqueName binding to avoid confusing jQuery Validation.
IE 6 does not allow radio buttons to be checked if they don’t have a name attribute. KO will internally use uniqueName on those elements to ensure they can be checked.
Parameter here will be Boolean value true or false or an expression resulting in Boolean like value. A unique name is generated by KO for the element for which this parameter is set to true or true-like value.
Let us take a look at the following example which demonstrates the use of uniqueName binding.
Let's carry out the following steps to see how the above code works −
Save the above code in uniquename-bind.htm file.
Open this HTML file in a browser.
Press F12 and observe the rendered markup. Unique name is generated by KO.