Browsing the NativeScript category

Nativescript get value of textfield

I had to get the value of a textfield using JavaScript in NativeScript; I tried a bunch of things and ended up just using a global variable to bind it.

XML:

<TextField id=”searchBox” text=”{{searchContents}}” />

And in the <Page> tag, add in:

loaded=”loaded”

JavaScript:

var model = {searchContents: “”};

exports.loaded = function(e){
var page = e.object;
page.bindingContext = model;
}

 

Then I could get it with model.searchContents;

Read the article

nativescript doesn’t scroll

I’m creating an app with NativeScript.  I’m using the Grid Layout, but I’m noticing that my content doesn’t scroll.

 

Solution: enclose everything in a <ScrollView>

Ex.

<ScrollView orientation="vertical" height="100%"  width="100%">
  <GridView Here...>
</ScrollView>

Read the article

NativeScript installation error

I was getting an error trying to install NativeScript (on my Mac).  Here’s (part of) the error I got:

TypeError: Object function Object() { [native code] } has no method ‘assign’ at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/config/cmd-list.js:113:33)

 

The solution: I thought I had the right version of Node installed; but I didn’t.  Even after doing “brew update”.  I manually re-installed Node (going to the official site) to make sure I had the latest version; then I was able to run npm correctly.

Read the article