My next post describes another way to do dialoguing. If this method doesn’t work for you, try that one.
Sometimes you need a Kynetx app to have access to the data on a page in the user’s browser, but you can’t do all the processing you need on the client side. Here’s an example:
The process is pretty simple. It goes like this:
- The rule also puts a hidden form on the page. The script adds the extracted data into fields on that form.
- When the script finishes collecting the data, it triggers the submit action on the form.
- All the while, this first rule has been
watch()ing for that form to be submitted.
- The second rule handles the event that gets raised (through
watch()) when the form is submitted.
- That rule extracts the data from the form and does any necessary operations with it (API lookups, storage, etc.) and takes appropriate actions.
Here’s a simplified version of the first rule from the BookComparison app:
You’ll notice we’re creating a series of input elements all with the name
isbnList and some subscript. This will come in useful in the next rule, where we can
foreach over those inputs. Here’s the second rule:
This second rule handles a
web submit event with the ID of the form given in quotes. Thereafter, it iterates over each of the ISBN numbers returned from the form. In the original app, this involved looking up the ISBN number in the Amazon API and then returning the price data back to the page (via an action like