Skip to content

Commit b90fa83

Browse files
committed
Update hello world component example.
1 parent 2d48fca commit b90fa83

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

example/unicorn/components/hello_world.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from django.utils.timezone import now
2+
13
from django_unicorn.components import UnicornView
24

35

@@ -8,3 +10,4 @@ class HelloWorldView(UnicornView):
810

911
def set_name(self):
1012
self.name = "set_name method called"
13+
return "set_name called at " + now().strftime("%H:%M:%S.%f")

example/unicorn/templates/unicorn/hello-world-test.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div>
22
<button unicorn:click="$reset">Reset the component</button>
3+
<button onclick="document.getElementById('name').value = 'asdf';">Plain JS set value on key1</button>
4+
<button onclick="Unicorn.trigger('unicorn.components.hello_world.HelloWorldView', 'key1')">Trigger key1</button>
35
<br />
46
<br />
57

0 commit comments

Comments
 (0)