[go-nuts] Re: Go wasm - package js - Set() fails for certain attributes

2019-03-30 Thread whitehexagon via golang-nuts
I haven't done much client side javascript, but I'm used to seeing 'class' 
and 'onClick' as attributes on a div or button.   Strange that no errors 
were generated anywhere, but anyway, both tips work perfectly, Thanks!!  
Peter

On Saturday, 30 March 2019 20:28:56 UTC+1, Rusco wrote:
>
> If you try out your code in Javascript you can spot your error, it would 
> be something like:
>
> but.className = "somecssclass";
> but.addEventListener("click", somefunction);
>
>
> so for syscall/js (untested) something like:
>
> var cb js.Callback cb = js.NewCallback(func(args []js.Value) { 
> fmt.Println("Clicked") }) but.Set("className", "button42") 
> but.Call("addEventListener", "click", cb)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Go wasm - package js - Set() fails for certain attributes

2019-03-30 Thread Rusco
If you try out your code in Javascript you can spot your error, it would be 
something like:

but.className = "somecssclass";
but.addEventListener("click", somefunction);


so for syscall/js (untested) something like:

var cb js.Callback cb = js.NewCallback(func(args []js.Value) { 
fmt.Println("Clicked") }) but.Set("className", "button42") 
but.Call("addEventListener", "click", cb)





On Saturday, 30 March 2019 12:01:45 UTC, whiteh...@googlemail.com wrote:
>
> So I create a html button, and try to set some attributes, some work, some 
> fail, is there a reason for this?
>
>
> but := doc.Call("createElement", "button")
> but.Set("id", bID) //works
> but.Set("innerHTML", "Don't Panic") //works
> but.Set("title", "mybuton") //works
> but.Set("class", "button42") //does not work
> but.Set("onClick", "pressed();") //does not work
>
> Thanks, Peter
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.