jquery bindings for ghcjs
ghcjs / ghcjs-jquery Goto Github PK
View Code? Open in Web Editor NEWjQuery bindings
License: MIT License
jQuery bindings
License: MIT License
This is due to c5eeeaf and happens if GHCJS_BROWSER
is defined. (I'm not really sure why nobody has reported this problem before. It could be something else about the way we're building our app, but I'm not really sure what that would be.)
Should the line be changed as follows?
- if ( h$isNode ) return;
+ if (typeof h$isNode !== "undefined") return;
I put in some of the work to port this to improved-base, but I need to switch gears, so I put up my WIP branch here: https://github.com/mgsloan/ghcjs-jquery/tree/improved-base
If anyone wants to carry this branch forward, let me know here! I'll hopefully revisit this in a week or two.
Consider blur - it's overloaded to either be a mutation or register an event handler. It is weird to me that the event handler thing is getting this name rather than the action, particularly as blur
. To me, code with this reads really strangely without the on
.
So, I'd say all jquery event registration things should start with on
. I'm not changing this, for now. Maybe once improved-base stabilizes, stuff like this can get fixed up.
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.
event handling is implemented by having a thread block on an MVar
that is passed to JS. GHCJS sends a 'Thread blocked indefinitely on an MVar operationto the thread now, since nothing in the Haskell world has another reference to that
MVar`, which means that no further events will be processed.
This makes much of this library rather useless, so it should really be fixed.
In the cabal file, ghcjs-dom has no version range and cabal install fails because it tries to use 0.2.1.0. Works with the previous version ghcjs-dom-0.1.1.3.
src/GHCJS/DOM.hs:19:8:
Could not find module ‘GHCJS.Types’
It is a member of the hidden package ‘ghcjs-base-0.1.0.0’.
Perhaps you need to add ‘ghcjs-base’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
src/GHCJS/DOM/EventTargetClosures.hs:9:8:
Could not find module ‘GHCJS.Foreign.Callback.Internal’
Use -v to see a list of the files searched for.
src/GHCJS/DOM/JSFFI/Generated/ANGLEInstancedArrays.hs:12:8:
Could not find module ‘GHCJS.Foreign’
It is a member of the hidden package ‘ghcjs-base-0.1.0.0’.
Perhaps you need to add ‘ghcjs-base’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
src/GHCJS/DOM/JSFFI/Generated/ANGLEInstancedArrays.hs:13:8:
Could not find module ‘GHCJS.Foreign.Callback’
Use -v to see a list of the files searched for.
src/GHCJS/DOM/JSFFI/Generated/ANGLEInstancedArrays.hs:14:8:
Could not find module ‘GHCJS.Marshal’
It is a member of the hidden package ‘ghcjs-base-0.1.0.0’.
Perhaps you need to add ‘ghcjs-base’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
src/GHCJS/DOM/JSFFI/Generated/ANGLEInstancedArrays.hs:15:8:
Could not find module ‘GHCJS.Marshal.Pure’
Perhaps you meant
GHCJS.Marshal (needs flag -package ghcjs-base-0.1.0.0)
Use -v to see a list of the files searched for.
-- Initial ghcjs-jquery.cabal generated by cabal init. For further
src/GHCJS/DOM/JSFFI/Geolocation.hs:15:8:
Could not find module ‘GHCJS.Prim’
It is a member of the hidden package ‘ghcjs-prim-0.1.0.0’.
Perhaps you need to add ‘ghcjs-prim’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
src/GHCJS/DOM/JSFFI/XMLHttpRequest.hs:18:8:
Could not find module ‘GHCJS.Marshal.Internal’
Perhaps you meant
GHCJS.Prim.Internal (needs flag -package ghcjs-prim-0.1.0.0)
Use -v to see a list of the files searched for.
src/GHCJS/DOM/Types.hs:858:8:
Could not find module ‘Data.JSString’
Perhaps you meant Data.String (from base)
Use -v to see a list of the files searched for.
src/GHCJS/DOM/Types.hs:859:8:
Could not find module ‘Data.JSString.Text’
Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
ghcjs-dom-0.2.1.0 failed during the building phase. The exception was:
ExitFailure 1
The following program should do nothing when the text is clicked, but the Ugh message appears anyway.
{-# LANGUAGE OverloadedStrings #-}
import Control.Monad (void)
import Data.Default
import Data.Text (Text)
import JavaScript.JQuery
default (Text)
main = do
body <- select "body"
button <- select "
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.