Skip to content

Error using jquery with time package #10

Closed
@govlas

Description

@govlas

code:

package main

import (
    "strconv"
    "time"

    "github.com/gopherjs/jquery"
)

var jq = jquery.NewJQuery

func main() {
    body := jq("body")
    content := jq("<div>").AppendTo(body)

    for i := 0; i < 10; i++ {

        content.SetHtml(strconv.Itoa(i))
        time.Sleep(time.Second)

    }
}

produces error in browser:

go-js.js:1738: Uncaught TypeError: Cannot read property 'ptr' of undefined

in function $externalize

    if (timePkg && v.constructor === timePkg.Time.ptr) {

timePkg.Time is not defined in javascript code

to solve the problem I add

var _ = time.Now()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions