text: (window.webpackJsonp=window.webpackJsonp||[]).push([[54],{109:function(e,t,r){"use strict";r.r(t),r.d(t,"frontMatter",(function(){return c})),r.d(t,"metadata",(function(){return u})),r.d(t,"rightToc",(function(){return s})),r.d(t,"default",(function(){return p}));var n=r(2),o=r(6),a=(r(0),r(302)),i=r(304),c={title:"Form / Textbox / Trigger",keywords:["form","textbox","trigger"]},u={unversionedId:"examples/textbox-trigger",id:"examples/textbox-trigger",isDocsHomePage:!1,title:"Form / Textbox / Trigger",description:"To handle live changes to a textbox, enable the trigger attribute.",source:"@site/docs/examples/textbox-trigger.md",slug:"/examples/textbox-trigger",permalink:"/wave/docs/examples/textbox-trigger",editUrl:"https://github.com/h2oai/wave/edit/master/website/docs/examples/textbox-trigger.md",version:"current",sidebar:"someSidebar",previous:{title:"Form / Textbox",permalink:"/wave/docs/examples/textbox"},next:{title:"Form / Button",permalink:"/wave/docs/examples/button"}},s=[],l={rightToc:s};function p(e){var t=e.components,c=Object(o.a)(e,["components"]);return Object(a.b)("wrapper",Object(n.a)({},l,c,{components:t,mdxType:"MDXLayout"}),Object(a.b)("p",null,"To handle live changes to a textbox, enable the ",Object(a.b)("inlineCode",{parentName:"p"},"trigger")," attribute."),Object(a.b)("div",{className:"cover",style:{backgroundImage:"url("+r(356).default+")"}}),Object(a.b)("pre",null,Object(a.b)("code",Object(n.a)({parentName:"pre"},{className:"language-py"}),"from h2o_wave import main, app, Q, ui\n\n\ndef to_pig_latin(text: str):\n    if text is None:\n        return ''\n    words = text.lower().strip().split(\" \")\n    text = []\n    for word in words:\n        if word[0] in 'aeiou':\n            text.append(f'{word}yay')\n        else:\n            for letter in word:\n                if letter in 'aeiou':\n                    text.append(f'{word[word.index(letter):]}{word[:word.index(letter)]}ay')\n                    break\n    return \" \".join(text)\n\n\n@app('/demo')\nasync def serve(q: Q):\n    q.page['example'] = ui.form_card(box='1 1 4 10', items=[\n        ui.textbox(name='text', label='English', value=q.args.text or '', multiline=True, trigger=True),\n        ui.label('Pig Latin'),\n        ui.text(to_pig_latin(q.args.text) or '*Type in some text above to translate to Pig Latin!*'),\n    ])\n    await q.page.save()\n")),Object(a.b)("p",null,Object(a.b)("strong",{parentName:"p"},"Tags"),": \u2002",Object(a.b)("a",{href:Object(i.a)("docs/examples/tags#form")},"form")," \u2002",Object(a.b)("a",{href:Object(i.a)("docs/examples/tags#textbox")},"textbox")," \u2002",Object(a.b)("a",{href:Object(i.a)("docs/examples/tags#trigger")},"trigger")))}p.isMDXComponent=!0},302:function(e,t,r){"use strict";r.d(t,"a",(function(){return p})),r.d(t,"b",(function(){return d}));var n=r(0),o=r.n(n);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function u(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var s=o.a.createContext({}),l=function(e){var t=o.a.useContext(s),r=t;return e&&(r="function"==typeof e?e(t):c(c({},t),e)),r},p=function(e){var t=l(e.components);return o.a.createElement(s.Provider,{value:t},e.children)},b={inlineCode:"code",wrapper:function(e){var t=e.children;return o.a.createElement(o.a.Fragment,{},t)}},f=o.a.forwardRef((function(e,t){var r=e.components,n=e.mdxType,a=e.originalType,i=e.parentName,s=u(e,["components","mdxType","originalType","parentName"]),p=l(r),f=n,d=p["".concat(i,".").concat(f)]||p[f]||b[f]||a;return r?o.a.createElement(d,c(c({ref:t},s),{},{components:r})):o.a.createElement(d,c({ref:t},s))}));function d(e,t){var r=arguments,n=t&&t.mdxType;if("string"==typeof e||n){var a=r.length,i=new Array(a);i[0]=f;var c={};for(var u in t)hasOwnProperty.call(t,u)&&(c[u]=t[u]);c.originalType=e,c.mdxType="string"==typeof e?e:n,i[1]=c;for(var s=2;s<a;s++)i[s]=r[s];return o.a.createElement.apply(null,i)}return o.a.createElement.apply(null,r)}f.displayName="MDXCreateElement"},303:function(e,t,r){"use strict";var n=r(0),o=r(19);t.a=function(){var e=Object(n.useContext)(o.a);if(null===e)throw new Error("Docusaurus context not provided");return e}},304:function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return i}));var n=r(303),o=r(305);function a(){var e=Object(n.a)().siteConfig,t=(e=void 0===e?{}:e).baseUrl,r=void 0===t?"/":t,a=e.url;return{withBaseUrl:function(e,t){return function(e,t,r,n){var a=void 0===n?{}:n,i=a.forcePrependBaseUrl,c=void 0!==i&&i,u=a.absolute,s=void 0!==u&&u;if(!r)return r;if(r.startsWith("#"))return r;if(Object(o.b)(r))return r;if(c)return t+r;var l=r.startsWith(t)?r:t+r.replace(/^\//,"");return s?e+l:l}(a,r,e,t)}}}function i(e,t){return void 0===t&&(t={}),(0,a().withBaseUrl)(e,t)}},305:function(e,t,r){"use strict";function n(e){return!0===/^(\w*:|\/\/)/.test(e)}function o(e){return void 0!==e&&!n(e)}r.d(t,"b",(function(){return n})),r.d(t,"a",(function(){return o}))},356:function(e,t,r){"use strict";r.r(t),t.default=r.p+"assets/images/textbox-trigger-3063508395dc193e6087e98ec3caf604.png"}}]);