Skip to content

Add missing param method #19

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

Merged
merged 1 commit into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,23 @@ trait JQueryStatic extends js.Object {
* See: <a href="http://api.jquery.com/jQuery.isXMLDoc/">jQuery Docs</a> */
def isXMLDoc[T](el: js.Any): Boolean = js.native

/** Create a serialized representation of an array, a plain object, or a jQuery object suitable
* for use in a URL query string or Ajax request. In case a jQuery object is passed, it should
* contain input elements with name/value properties. <br/>
* See: <a href="http://api.jquery.com/jQuery.param/">jQuery Docs</a> */
def param(obj: js.Array[js.Any] | js.Object | JQuery, traditional: Boolean = js.native): String = js.native

/** Parses a string into an array of DOM nodes. <br/>
* See: <a href="http://api.jquery.com/jQuery.isXMLDoc/">jQuery Docs</a> */
* See: <a href="http://api.jquery.com/jQuery.parseHTML/">jQuery Docs</a> */
def parseHTML(data: String, context: Element = js.native, keepScripts: Boolean = js.native): js.Array[Element] = js.native

/** Takes a well-formed JSON string and returns the resulting JavaScript value. <br/>
* See: <a href="http://api.jquery.com/jQuery.isXMLDoc/">jQuery Docs</a> */
* See: <a href="http://api.jquery.com/jQuery.parseJSON/">jQuery Docs</a> */
@deprecated("Since all the browsers supported by jQuery 3.0 support the native JSON.parse() method, we are deprecating jQuery.parseJSON().", "1.1.0")
def parseJSON(json: String): js.Any = js.native

/** Parses a string into an XML document. <br/>
* See: <a href="http://api.jquery.com/jQuery.isXMLDoc/">jQuery Docs</a> */
* See: <a href="http://api.jquery.com/jQuery.parseXML/">jQuery Docs</a> */
def parseXML(xml: String): js.Dynamic = js.native

/** Load data from the server using a HTTP POST request. <br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class MiscellaneousTest extends WordSpec with Matchers {
selection.index(jQ(el3)) should be(2)
selection.index(el4) should be(-1)
}

"serialize objects to URL query string" in {
import scala.scalajs.js, js.JSConverters._
jQ.param(js.Dynamic.literal("a" -> Seq(1, 2, 3).toJSArray, "b" -> "c")) should be("a%5B%5D=1&a%5B%5D=2&a%5B%5D=3&b=c")
}
}

}