-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample code to replicate issue #397.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import Dict | ||
|
||
from django_unicorn.components import UnicornView | ||
|
||
|
||
class Issue397View(UnicornView): | ||
counter: int = 1 | ||
counter2: Dict = None | ||
|
||
def mount(self): | ||
self.counter2 = {"more": 8} | ||
|
||
def inc(self): | ||
self.counter += 1 | ||
self.counter2["more"] += 1 | ||
|
||
def updated_counter(self, value): | ||
print(f"updated_counter: {value}") | ||
|
||
def updated_counter2(self, value): | ||
print(f"updated_counter2: {value}") | ||
|
||
def updated(self, name, value): | ||
print(f"updated: {name}, {value}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends "www/base.html" %} | ||
{% load unicorn %} | ||
|
||
{% block content %} | ||
|
||
<div unicorn:view> | ||
<div> | ||
counter: {{ counter }} | ||
</div> | ||
<div> | ||
counter2.more: {{ counter2.more }} | ||
</div> | ||
|
||
<div> | ||
<button unicorn:click="inc">inc</button> | ||
</div> | ||
|
||
<div> | ||
<button unicorn:click="counter=4">counter=4</button> | ||
</div> | ||
|
||
<div> | ||
<button unicorn:click="counter2.more=4">counter2.more=4</button> | ||
</div> | ||
</div> | ||
|
||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters