Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get textview not working #326

Open
Gurucharan opened this issue Jan 10, 2019 · 0 comments
Open

get textview not working #326

Gurucharan opened this issue Jan 10, 2019 · 0 comments

Comments

@Gurucharan
Copy link

Gurucharan commented Jan 10, 2019

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant