Go to the source code of this file.
|
| with_js () |
| Note, counters also offer an interface for manipulations through JS. More...
|
|
◆ with_js()
Note, counters also offer an interface for manipulations through JS.
Checkout: src/UI/templates/js/Counter/counter.js for a complete spec.
Example Usage: //Step 1: Get the counter Object var counter = il.UI.counter.getCounterObject($some_jquery_object); //Step 2: Do stuff with the counter Object var novelty_count = counter.setNoveltyCount(3).getNoveltyCount(); //novelty count should be 3 novelty_count = counter.setNoveltyToStatus().getNoveltyCount(); //novelty count should be 0, status count 3
Definition at line 14 of file with_js.php.
References $DIC, and Vendor\Package\$f.
17 $f = $DIC->ui()->factory();
18 $renderer = $DIC->ui()->renderer();
21 $like =
$f->symbol()->glyph()->love(
"#")
22 ->withCounter(
$f->counter()->novelty(3))
23 ->withCounter(
$f->counter()->status(0));
25 $set_status_button =
$f->button()->bulky($like,
"Set Status Counter to 10 on click.",
"#")
26 ->withAdditionalOnLoadCode(
29 $(\"#$id\").click(function() { 30 il.UI.counter.getCounterObject($(this)).setStatusTo(10); 35 $increment_novelty_button =
$f->button()->bulky($like,
"Increment Novelty Counter by on click",
"#")
36 ->withAdditionalOnLoadCode(
39 $(\"#$id\").click(function() { 40 il.UI.counter.getCounterObject($(this)).incrementNoveltyCount(1); 45 $set_novelty_count_to_status_button =
$f->button()->bulky($like,
"Set Novelty Count to status on click",
"#")
46 ->withAdditionalOnLoadCode(
49 $(\"#$id\").click(function() { 50 il.UI.counter.getCounterObject($(this)).setTotalNoveltyToStatusCount(1); 56 $combined_button =
$f->button()->bulky($like,
"Some chained actions",
"#")
57 ->withAdditionalOnLoadCode(
60 $(\"#$id\").click(function() { 61 var counter = il.UI.counter.getCounterObject($(this)); 62 counter.setNoveltyTo(3); 63 counter.setStatusTo(3); 64 counter.incrementStatusCount(1); 65 counter.setTotalNoveltyToStatusCount(); 67 counter.getStatusCount() 73 return $renderer->render([$set_status_button,$increment_novelty_button,$set_novelty_count_to_status_button,$combined_button]);