Skip to content
Sheng Zhao edited this page Jul 9, 2015 · 10 revisions

Knot Variant intends to provide a convenient way to enable use binding to system level status such as hash status, loading status etc...
The name of Knot Variant always start with "$". It can be directly accessed from CBS by the variant name or from Javascript by calling Knot.setKnotVariant(variantName, value) and Knot.setKnotVariant(variantName)

Here is the list for the Knot Variants:

$hash : the hash status of current window.

  • Use $hash.originalHash to get/set the original hash string.
  • Use $hash.[hash variant name]to get/set the hash variant. To access hash variants, you need to tell knot.js how to parse them by calling Knot.setHashFormat([variants name array], splitter);
    Example: Knot.setHashFormat(["category", "bookId"], "/") tells knot.js that hash status string is composed by "category" and "bookId", and splitted by "/".
    With this setting and hash status string of "bestseller/123", $hash.category returns "bestseller" and $hash.bookId returns "123". Note you can also set these two hash variants, window's hash status will change accordingly