Skip to content

Failed to use with another JQuery-based library #10

Open
@spl

Description

I apologize in advance for the poor description in this issue. I'm not really sure what the problem is, but I thought I would leave this here in case other people run into a similar problem.

I'm trying to use Flot, a JQuery-based library for plotting charts. If I use ghcjs-jquery, the Flot code (jquery.flot.js) does not load properly.** That is, it does not extend the jQuery object with its functionality, such as adding a plot function. If I use the simple FFI below (with a static jquery.js and without using ghcjs-jquery), the Flot code works. I only need selectElement at this point.

type JQuery = JSRef JQuery_
data JQuery_

selectElement :: (MonadIO m, IsElement e) => e -> m JQuery
selectElement = liftIO . jq_selectElement . unElement . toElement

foreign import javascript unsafe "jQuery($1)" jq_selectElement :: JSRef Element -> IO JQuery

** Using ghcjs-jquery, I have seen Flot work intermittently (once in a while on refresh). With only the above, it works consistently.

My guess is that the JavaScript loading is somehow causing the problem. Our output JS is relatively large.

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