Skip to content

Commit c60d142

Browse files
authored
Merge pull request #19 from UdashFramework/jq-param
Add missing `param` method
2 parents 64cb3e0 + 96c7cbc commit c60d142

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/scala/io/udash/wrappers/jquery/JQueryStatic.scala

+9-3
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,23 @@ trait JQueryStatic extends js.Object {
129129
* See: <a href="http://api.jquery.com/jQuery.isXMLDoc/">jQuery Docs</a> */
130130
def isXMLDoc[T](el: js.Any): Boolean = js.native
131131

132+
/** Create a serialized representation of an array, a plain object, or a jQuery object suitable
133+
* for use in a URL query string or Ajax request. In case a jQuery object is passed, it should
134+
* contain input elements with name/value properties. <br/>
135+
* See: <a href="http://api.jquery.com/jQuery.param/">jQuery Docs</a> */
136+
def param(obj: js.Array[js.Any] | js.Object | JQuery, traditional: Boolean = js.native): String = js.native
137+
132138
/** Parses a string into an array of DOM nodes. <br/>
133-
* See: <a href="http://api.jquery.com/jQuery.isXMLDoc/">jQuery Docs</a> */
139+
* See: <a href="http://api.jquery.com/jQuery.parseHTML/">jQuery Docs</a> */
134140
def parseHTML(data: String, context: Element = js.native, keepScripts: Boolean = js.native): js.Array[Element] = js.native
135141

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

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

145151
/** Load data from the server using a HTTP POST request. <br/>

src/test/scala/io/udash/wrappers/jquery_test/MiscellaneousTest.scala

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class MiscellaneousTest extends WordSpec with Matchers {
4343
selection.index(jQ(el3)) should be(2)
4444
selection.index(el4) should be(-1)
4545
}
46+
47+
"serialize objects to URL query string" in {
48+
import scala.scalajs.js, js.JSConverters._
49+
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")
50+
}
4651
}
4752

4853
}

0 commit comments

Comments
 (0)