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

Method name not found in JavaScript compilation #166

Closed
AndreiDegtiarev opened this issue Mar 31, 2018 · 6 comments
Closed

Method name not found in JavaScript compilation #166

AndreiDegtiarev opened this issue Mar 31, 2018 · 6 comments

Comments

@AndreiDegtiarev
Copy link

AndreiDegtiarev commented Mar 31, 2018

After migration from Websharper.UI.Next to Websharper.UI, the code

let Main () = (div[] []).OnMouseDown(fun _ _ ->()) 

yields the build error:

error FS9001: Method name not found in JavaScript compilation: (OnMouseDown : Microsoft.FSharp.Quotations.FSharpExpr`1<(WebSharper.JavaScript.Dom.Element -> (WebSharper.JavaScript.Dom.MouseEvent -> unit))> -> WebSharper.UI.Elt), Members: get_Element, AddClass', ClearHoles, AddHole, onExpr, SetStyle', HasClass', RemoveClass', GetProperty', SetProperty', RemoveAttribute', HasAttribute', GetAttribute', SetAttribute', SetText, GetText, SetValue, GetValue, Id', Html', Clear', PrependDoc, AppendDoc, TreeNode, New, ToUpdater, OnAfterRenderView, OnAfterRender, onView, on
@granicz
Copy link
Member

granicz commented Mar 31, 2018

I believe the update to UI didn't go correctly in your project - the above code should still work just fine. You might want to remove all UI.Next references (confirming in the project files as well) and re-adding the UI ones.

@Tarmil
Copy link
Member

Tarmil commented Apr 2, 2018

Actually I think this is because we are missing proxies for the quotation-based version of these methods. We should definitely (re-?)add them. But in the meantime, you should use open WebSharper.UI.Client to bring the client-side only, non-quotation-based method.

@Tarmil Tarmil closed this as completed in da5d43f Apr 3, 2018
@AndreiDegtiarev
Copy link
Author

Could you please point me how I can use “WebSharper.UI.Client” for handling of mouse events?

@RobBarton
Copy link

I encountered the same problem during a 3 -> 4 upgrade. This might work for you:
let Main () = DocExtensions.OnMouseDown (div [] [], fun _ _ -> ())

@Tarmil
Copy link
Member

Tarmil commented Apr 4, 2018

Or you can set the event handler as an attribute:

let Main () =
    div [ on.mouseDown (fun _ _ -> ()) ] []

@AndreiDegtiarev
Copy link
Author

Thank you for the help. It works now.

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

No branches or pull requests

4 participants