Skip to content

get textview not working #326

@Gurucharan

Description

@Gurucharan

Hello,
I was trying to get the user input from the text view. but it shows exception. please help me on this issue.

const editState = vm.get("editState");
console.log(editState);

Full Code is here.

main-page.js

// >> list-view-create-code
const fromObject = require("tns-core-modules/data/observable").fromObject;

var view = require("tns-core-modules/ui/core/view");

var dialogs = require("tns-core-modules/ui/dialogs");
var new_note_title;

function onNavigatingTo(args) {
const page = args.object;
const vm = fromObject({
// Setting the listview binding source
myTitles: [
{ title: "going to gym" },
{ title: "electricity bill due date" },
{ title: "need to buy one book" },
{ title: "tank fill petrol" },
{ title: "insurance premium bill" },
{ title: "lunch bag" }
]
});
page.bindingContext = vm;
}
exports.onNavigatingTo = onNavigatingTo;

function onListViewLoaded(args) {
const listView = args.object;
}
exports.onListViewLoaded = onListViewLoaded;

function onItemTap(args) {
const index = args.index;
console.log(Second ListView item tap ${index});
}
exports.onItemTap = onItemTap;
// << list-view-create-code

function onTap(args) {

const page = args.object.page;
const vm = page.bindingContext;
// >> list-view-refresh
const listView = page.getViewById("listView");
page.bindingContext.myTitles.push({ title: new_note_title });
// Manually trigger the update so that the new color is shown.
listView.refresh();
// << list-view-refresh

}
exports.onTap = onTap;

function newNote(args){

const button = args.object;
const page = button.page;
page.frame.navigate("add-item");

}
exports.newNote = newNote;

add-item.js

const fromObject = require("tns-core-modules/data/observable").fromObject;

exports.onPageLoaded = function(args) {
}

function onCreateTap(args) {
const button = args.object;
const page = button.page;
const vm = page.bindingContext;
const editState = vm.get("editState");
console.log(editState);
page.frame.navigate("main-page");
}
exports.onCreateTap = onCreateTap;

add-item.xml

<StackLayout>
    <TextView id="title" text="{{ item_title }}" hint="enter the title" editable="{{ editState }}" />
    <Button text="Create" tap="onCreateTap" class="btn btn-primary btn-active" />
</StackLayout>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions