jducoeur / jquery-facade Goto Github PK
View Code? Open in Web Editor NEWA strongly-typed Scala.js facade for jQuery
A strongly-typed Scala.js facade for jQuery
Here is the code:
$("ul li").after((elem: dom.Element, idx: Int) => ("index: " + idx: ElementDesc))
If I break down the call as:
val tf: js.ThisFunction1[dom.Element, Int, ElementDesc] = (e: dom.Element, i: Int) => {
println("adding index...")
("index: " + i): ElementDesc
}
val ulli = $("ul li")
println(ulli)
println(tf)
ulli.after(tf)
Then I can see "adding index..." printed in the console, but the elements were not added.
jQuery lets you write $('#agenda').load(url)
, it would be nice to be able to do that in scalajs
Hi,
First of all I'd like to say thank you for a great and useful library.
Scala 3 seems to be quite mature and it would be very nice to have scala 3 support in this library.
I see that there's already a pull request to implement scala 3 support.
I know you probably have very little time and much more important things to do, so I'd like to know if there are any plans to merge it in the future?
Hi there
Could you publish an artifact for ScalaJS 1.0.0-M3 or are you awaiting the stable release?
Cheers!
Raphael
How would I send data from a triggered event to the event listener.
for example
$(dom.document).trigger("my-event", ???data-goes-here???)
$(dom.document).on("my-event", (e: JQueryEventObject)=>{
})
Any plans to make a new release for Scala-2.13?
I can't find any ajax methods in the facade library
Hi
Could this facade be built against scala-js-dom 0.9.0. I get some warnings that jquery-facade is still working against version 0.8.0
Please, crosscompile to scala 2.12
I'm having trouble getting data with an ajax request.
I have the code
val myPromise = $.ajax(url)
myPromise.done((data: Any, textStatus: String, jqXHr: JQueryXHR) => {
println(data)
})
in the console log I get [object Object]
if I try to match data
I get
Uncaught TypeError: Cannot read property 'getName__T' of null
I checked the textStatus
and it returns success. I've also checked the request in the chrome dev tools and it is returning a json string. How do I use that json string after I've recieved it?
I have this in my build.sbt:
lazy val client = project .settings( libraryDependencies ++= Seq( "org.querki" %%% "jquery-facade" % "2.0" ) ).dependsOn(shared)
When I start sbt, I get this:
(client / update) sbt.librarymanagement.ResolveException: Error downloading org.querki:jquery-facade_2.13:2.0 Not found Not found not found: /Users/lance/.ivy2/local/org.querki/jquery-facade_2.13/2.0/ivys/ivy.xml not found: https://repo1.maven.org/maven2/org/querki/jquery-facade_2.13/2.0/jquery-facade_2.13-2.0.pom (client / ssExtractDependencies) sbt.librarymanagement.ResolveException: Error downloading org.querki:jquery-facade_2.13:2.0 Not found Not found not found: /Users/lance/.ivy2/local/org.querki/jquery-facade_2.13/2.0/ivys/ivy.xml not found: https://repo1.maven.org/maven2/org/querki/jquery-facade_2.13/2.0/jquery-facade_2.13-2.0.pom Total time: 1 s, completed 23 Oct 2020, 20:18:32
object JQueryStatic
maps to a global jQuery
object.
I use jQuery.noConflict()
to scope a specific version of jQuery. So I don't think I can use JQueryStatic
as is.
Maybe splitting it into a trait and an object could help:
trait JQueryStatic { ... }
object JQueryStatic extends JQueryStatic
With the regular org.scalajs.jquery.JQueryStatic
from scala-js/scala-js-jquery
, which is a trait, I can do just that:
val $ = g.MY.jQuery.asInstanceOf[org.scalajs.jquery.JQueryStatic]
See also how a default scala-js/scala-js-jquery
scopes a default org.scalajs.jquery.JQueryStatic
here.
Would it be possible to publish jquery-facade for scalajs-dom v2.0.0? As stated in the release notes, the 2.x series is not binary-compatible with the 1.x series. So, for projects that use v2.0.0 and jquery-facade, the latter needs to be built against v2.0.0.
It seems, simply updating the dependency suffices:
libraryDependencies ++= Seq(
"org.querki" %%% "querki-jsext" % "0.10",
- "org.scala-js" %%% "scalajs-dom" % "0.9.8"
+ "org.scala-js" %%% "scalajs-dom" % "2.0.0"
)
According to css specification scrollTop is defined as floating type.
When I try to get an element using $("#id") it gives me following error message.
ambiguous reference to overloaded definition,
both method apply in object JQueryStatic of type (obj: scala.scalajs.js.Object)org.querki.jquery.JQuery
and method apply in object JQueryStatic of type (selector: org.querki.jquery.ElementDesc)org.querki.jquery.JQuery
match argument types (String)
Please, update jsext dependency
@sjrd has pointed out that Scala.js default parameters are a good option for messy optionals. We should try that out, and see how it works.
The really interesting situation is when you want to omit some of the optionals in the middle; @sjrd favors using named parameters at the call site for those situations. That's plausible, but I don't know whether I want to require it or not. In some places, switching to purely that would be a breaking change, so I don't think I favor removing the spelled-out versions. But we might add "master signatures" using defaults, and favor that approach going forward.
I am trying to iterate over options using val x = $(selectState).find("option").each((y: Element) => y)
. However Compilation throw following error.
type mismatch;
found : org.scalajs.dom.Element => org.scalajs.dom.Element
(which expands to) org.scalajs.dom.raw.Element => org.scalajs.dom.raw.Element
required: scala.scalajs.js.|[scala.scalajs.js.ThisFunction0[org.scalajs.dom.Element,Any],scala.scalajs.js.ThisFunction1[org.scalajs.dom.Element,Int,Any]]
(which expands to) scala.scalajs.js.|[scala.scalajs.js.ThisFunction0[org.scalajs.dom.raw.Element,Any],scala.scalajs.js.ThisFunction1[org.scalajs.dom.raw.Element,Int,Any]]
I was referring to stack overflow question. Is it changed in recent library?
Hi Justin,
did to you plan to move to jquery 2.2.1 ? I tried it, it works except for the cross compilation with scala 2.10.
Mathieu
Since scala-js-jquery
is no longer maintained, I would like to contribute to jquery-facade
so it can survice on a long-term basis.
jquery-facade
supports many Scala versions.
It would be benefical if project introduces CI (Travis or CircleCI, e.g.) to perform cross-building on each PR to ensure change does not break build, from contributor perspective.
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.