UNPKG

prismic.io

Version:

JavaScript development kit for prismic.io

1,720 lines (470 loc) 20.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: SearchForm</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: SearchForm</h1> <section> <header> <h2>SearchForm</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="SearchForm"><span class="type-signature"></span>new SearchForm<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> Embodies a SearchForm object. To create SearchForm objects that are allowed in the API, please use the API.form() method. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line592">line 592</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="fetch"><span class="type-signature"></span>fetch<span class="signature">(fields)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Restrict the results document to the specified fields </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>fields</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">array</span> </td> <td class="description last">The list of fields, array or comma separated string</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line687">line 687</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="fetchLinks"><span class="type-signature"></span>fetchLinks<span class="signature">(fields)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Include the requested fields in the DocumentLink instances in the result </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>fields</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">array</span> </td> <td class="description last">The list of fields, array or comma separated string</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line700">line 700</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="lang"><span class="type-signature"></span>lang<span class="signature">(fields)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Sets the language to query for this SearchForm. This is an optional method. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>fields</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The language code</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line713">line 713</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="orderings"><span class="type-signature"></span>orderings<span class="signature">(orderings)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Sets the orderings to query for this SearchForm. This is an optional method. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>orderings</code></td> <td class="type"> <span class="param-type">array</span> </td> <td class="description last">Array of string: list of fields, optionally followed by space and desc. Example: ['my.product.price desc', 'my.product.date']</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line733">line 733</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="page"><span class="type-signature"></span>page<span class="signature">(p)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Sets the page number to query for this SearchForm. This is an optional method. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>p</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">The page number</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line723">line 723</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="pageSize"><span class="type-signature"></span>pageSize<span class="signature">(size)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Sets a page size to query for this SearchForm. This is an optional method. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>size</code></td> <td class="type"> <span class="param-type">number</span> </td> <td class="description last">The page size</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line677">line 677</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="query"><span class="type-signature"></span>query<span class="signature">(query)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Sets a predicate-based query for this SearchForm. This is where you paste what you compose in your prismic.io API browser. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>query</code></td> <td class="type"> <span class="param-type">string</span> | <span class="param-type">array</span> </td> <td class="description last">Either a query as a string, or as many predicates as you want. See Prismic.Predicates.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line653">line 653</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h5>Example</h5> <pre class="prettyprint"><code>form.query(Prismic.Predicates.at("document.id", "foobar"))</code></pre> <h4 class="name" id="ref"><span class="type-signature"></span>ref<span class="signature">(ref)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Sets a ref to query on for this SearchForm. This is a mandatory method to call before calling submit(), and api.form('everything').submit() will not work. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>ref</code></td> <td class="type"> <span class="param-type"><a href="Ref.html">Ref</a></span> </td> <td class="description last">The Ref object defining the ref to query</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line641">line 641</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="set"><span class="type-signature"></span>set<span class="signature">(field, value)</span><span class="type-signature"> &rarr; {<a href="SearchForm.html">SearchForm</a>}</span></h4> <div class="description"> Set an API call parameter. This will only work if field is a valid field of the RESTful form in the first place (as described in the /api document); otherwise, an "Unknown field" error is thrown. Please prefer using dedicated methods like query(), orderings(), ... </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>field</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The name of the field to set</td> </tr> <tr> <td class="name"><code>value</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The value that gets assigned</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line616">line 616</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> - The SearchForm itself </div> <dl> <dt> Type </dt> <dd> <span class="param-type"><a href="SearchForm.html">SearchForm</a></span> </dd> </dl> <h4 class="name" id="submit"><span class="type-signature"></span>submit<span class="signature">(callback)</span><span class="type-signature"></span></h4> <div class="description"> Submits the query, and calls the callback function. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type">function</span> </td> <td class="description last">Optional callback function that is called after the query was made, to which you may pass three parameters: a potential error (null if no problem), a Response object (containing all the pagination specifics + the array of Docs), and the XMLHttpRequest</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="api.js.html">api.js</a>, <a href="api.js.html#line754">line 754</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Api.html">Api</a></li><li><a href="Doc.html">Doc</a></li><li><a href="Experiments.html">Experiments</a></li><li><a href="Fragments_Color.html">Fragments:Color</a></li><li><a href="Fragments_CompositeSlice.html">Fragments:CompositeSlice</a></li><li><a href="Fragments_Date.html">Fragments:Date</a></li><li><a href="Fragments_DocumentLink.html">Fragments:DocumentLink</a></li><li><a href="Fragments_Embed.html">Fragments:Embed</a></li><li><a href="Fragments_FileLink.html">Fragments:FileLink</a></li><li><a href="Fragments_GeoPoint.html">Fragments:GeoPoint</a></li><li><a href="Fragments_Group.html">Fragments:Group</a></li><li><a href="Fragments_ImageEl.html">Fragments:ImageEl</a></li><li><a href="Fragments_ImageLink.html">Fragments:ImageLink</a></li><li><a href="Fragments_ImageView.html">Fragments:ImageView</a></li><li><a href="Fragments_Num.html">Fragments:Num</a></li><li><a href="Fragments_Select.html">Fragments:Select</a></li><li><a href="Fragments_Separator.html">Fragments:Separator</a></li><li><a href="Fragments_SimpleSlice.html">Fragments:SimpleSlice</a></li><li><a href="Fragments_SliceZone.html">Fragments:SliceZone</a></li><li><a href="Fragments_StructuredText.html">Fragments:StructuredText</a></li><li><a href="Fragments_Text.html">Fragments:Text</a></li><li><a href="Fragments_Timestamp.html">Fragments:Timestamp</a></li><li><a href="Fragments_WebLink.html">Fragments:WebLink</a></li><li><a href="Ref.html">Ref</a></li><li><a href="Response.html">Response</a></li><li><a href="SearchForm.html">SearchForm</a></li><li><a href="WithFragments.html">WithFragments</a></li></ul><h3>Namespaces</h3><ul><li><a href="Predicates.html">Predicates</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ApiCache">ApiCache</a></li><li><a href="global.html#data">data</a></li><li><a href="global.html#fragments">fragments</a></li><li><a href="global.html#insertSpans">insertSpans</a></li><li><a href="global.html#LRUCache">LRUCache</a></li><li><a href="global.html#parseDoc">parseDoc</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Fri Apr 28 2017 17:29:54 GMT+0200 (CEST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>