-
Notifications
You must be signed in to change notification settings - Fork 18
Error using jquery with time package #10
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
Comments
Good catch ! I strongly suspect that it's a GopherJS isse and not related to any Dom manipulations done by jQuery or the jQuery Binding. For now my plan is trying to distill an example without jQuery involved and submit the issue to the GopherJS issues list . The following similar example works: package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/gopherjs/jquery"
"strconv"
"time"
)
func log(i ...interface{}) {
js.Global.Get("console").Call("log", i...)
}
var jq = jquery.NewJQuery
func main() {
for i := 0; i < 10; i++ {
jq("<div>" + strconv.Itoa(i) + "</div>").InsertAfter("body")
log(strconv.Itoa(i))
time.Sleep(time.Second)
}
} |
a shorter version to work on. I have a hard time to reproduce this without the jQuery dependency: package main
import (
"github.com/gopherjs/gopherjs/js"
"github.com/gopherjs/jquery"
"time"
)
func log(i ...interface{}) {
js.Global.Get("console").Call("log", i...)
}
//activate one "main" func:
func main_ok() {
body := jquery.NewJQuery("body")
//log(body)
_ = body
time.Sleep(time.Second)
log("done.")
}
func main_bug() {
body := jquery.NewJQuery("body")
log(body)
//_ = body
time.Sleep(time.Second)
log("done.")
} @neelance : In the first case the "Time" struct of the time package is available, in the second case it is "undefined". Could you have a look at this ? looks like a GopherJS topic |
So, this code without jquery does not work ;) package main
import (
"time"
"github.com/gopherjs/gopherjs/js"
)
//var _ = time.Now()
func log(i ...interface{}) {
js.Global.Get("console").Call("log", i...)
}
type Test struct {
A int
B string
}
func main() {
log(Test{1, "hello"})
time.Sleep(time.Second)
} |
Excellent ! Now this bug can be assigned directly to the gopherjs/gopherjs project and not jQuery. |
I'll do |
up to gopherjs/gopherjs#279 |
code:
produces error in browser:
in function $externalize
timePkg.Time is not defined in javascript code
to solve the problem I add
The text was updated successfully, but these errors were encountered: