navigate.link()method as this allows us to link one screen to another, and allows the user to navigate back and forth through our app, as you'll see shortly. The Navigation methods are available from your view JS code.
object-listcomponent in your
buttonand select the auto-complete suggestion for a plain
<button>. Now fill in a label for your button, something like 'Add New Item', and enter the name of the JS function that you want to call when the button is pressed, e.g.
goToNewas seen below:
main.js, underneath the
resume()function, add the following code (make sure the name your function exactly as you have referenced it in the
on-pressattribute of your button)
navigate.link()method has one required argument and that is the
pathof the view you want to link to as a string. The
pathof the view is used as the unique identifier of each view.
navigate.link()method to a view called
add_new, but that view does not exist yet because we haven't created it yet. So now we need to create this
add_newview in our app. To add a new view you can click on the '+' icon in the views panel in the top left corner of the Views Workspace. When prompted to enter a name or path for the view, simply enter
add_new. (Note, the argument that you pass into the
navigate.link()function needs to match the name/path of the view you want to link to).
title(it would have defaulted to the name/path of the view), then we will add a way for users to capture new punch list item objects.
add_newview, to do this simply click on the name/path of the new view in the Views Panel on the left of the Views Workspace.
titleof the view, simply update the text value inside of the
<view title="">attribute to something like:
<view title="Add New Punch Item">.
init()function. Since we want users to create new punch list items, start by adding a variable to your View XML that will store the new punch list item underneath the
<!-- Variables go here: -->:
init()function. This is done calling the
create()method on the DB Model in question:
statusfield in our
itemmodel is a
single-choicetype field, and the options for that field is specified using
key|valuepairs listed as options within the field. When we want to populate this field programmatically we will always be using
keys, not the
text-inputcomponents. Let's add those to our view now underneath
<!-- Components go here: -->:
bindproperties, we refer to the attributes of the item object stored in the variable containing our blank punch list item, therefore using the syntax
add_newview should look this like. XML