Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events not found #9

Closed
cwbriscoe opened this issue May 22, 2016 · 2 comments
Closed

Events not found #9

cwbriscoe opened this issue May 22, 2016 · 2 comments

Comments

@cwbriscoe
Copy link

I am not sure if this is a bug, if I am doing something wrong or what. In my changes to one of the examples below, I am trying to trigger an event when the submit button is clicked. However, I get the following error:

Uncaught ReferenceError: handleSubmitClick is not defined 
diff --git a/examples/databind-event-callback/main.go b/examples/databind-event-callback/main.go
index f9fb5aa..d9b7133 100644
--- a/examples/databind-event-callback/main.go
+++ b/examples/databind-event-callback/main.go
@@ -34,4 +34,10 @@ func (n *NameTag) HandleNameChange(e *polymer.Event) {
        })
 }

+func (n *NameTag) HandleSubmitClick(e *polymer.Event) {
+       polymer.Async(1, func() {
+               polymer.Log("Submit clicked")
+       })
+}
+
 func main() {}
diff --git a/examples/databind-event-callback/name-tag.html b/examples/databind-event-callback/name-tag.html
index 2ec151b..ce36d90 100644
--- a/examples/databind-event-callback/name-tag.html
+++ b/examples/databind-event-callback/name-tag.html
@@ -15,6 +15,7 @@
                The go code bound to it will output the name to the console using fmt.Printf. See main.go.<br />
                Each name-tag element is also completely independent, backed by a different instance of the NameTag structure<br />
                The Go generated ID of this particular name tag is <b>{{id}}</b>
+               Name: <input type="submit"  onclick="handleSubmitClick" /><br />
        </template>
        <script>PolymerGo("name-tag")</script>
-</dom-module>
\ No newline at end of file
+</dom-module>

I get the same error when I try to use a property change event like this:

<child-component timer-value="{{timerValue}}" on-timer-value-changed="handleTimerValueChanged"></child-component>

However, if I do this in the Created function, it works:

func (c *ChildComponent) Created() {
                c.This().Call("addEventListener", "timer-value-changed", c.HandleTimerValueChanged)
}
@luna-duclos
Copy link

I'm sorry, I've been quite busy lately, I'll try looking at this today

@cwbriscoe
Copy link
Author

No worries as there is a workaround by using "addEventListener".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants