Pregunta

I have just started to use Haxe and imported the jQueryExtern, when I'm trying to use

        new JQuery(".roles:checked").each(function(){

        });

I'm getting a Compiler error:

src/LeftList.hx:69: lines 69-71 : Void -> Void should be Int -> js.html.Node -> Void
src/LeftList.hx:69: lines 69-71 : For function argument '_function'

Can't figure out why,

Help will be much appreciated,

Nevo.

¿Fue útil?

Solución

The jQueryExtern project provides the following function definition:

public function each(_function:Int -> js.html.Node -> Void):jQuery.JQuery;

The thing to notice is that the function argument specifies that both "Int" and "Node" arguments must exist on the function - they are not optional. (If you think this is incorrect, maybe file an issue on the Github page for jQueryExternForHaxe?) Because Haxe is strictly typed, it will only accept a function that exactly matches the type signature used in the definition.

The following code should work:

    new JQuery(".roles:checked").each(function(index,node){
      $type(index); // Int
      $type(node); // js.html.Node
    });
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top