Giter Club home page Giter Club logo

ti.suggestions's Introduction

"Titanium" "Alloy" "License"

ti.suggestions

Titanium Axway Suggestions

As a user types text into TextField - this widget filters the array/results and populates a TableView Overlay

Demo

index.xml
<Widget id="categorySearchTextField" hintText="Begin typing for a list of categories..." src="ti.suggestions" onChange="handleChange" onExportData="handleExportData" onClear="handleClear" />
index.js
var categoriesArrayData =
    [{title: "Action Book [Books]", id: 1},
    {title: "Dog Food [Pet Supplies]", id: 2},
    {title: "Guitar [Musical Instruments]", id: 3},
    {title: "Refrigerator [Appliances]", id: 4},
    {title: "Xylophone [Musical Instruments]", id: 5}];

// SEND REQUEST TO GET NEW DATA
function handleChange(e) {			//e.value
    //Ti.API.info("Value Changed: " + $.categorySearchTextField.getValue());

    var filteredArray =
        _.filter(categoriesArrayData, function(element){
            return element.title.toLowerCase().indexOf( e.value.toLowerCase() ) > -1;
    });

    $.categorySearchTextField.setSuggestions(filteredArray);
}

// HANDLE RETURNED DATA WHEN USER CLICKED ON A SUGGESTION ROW
function handleExportData(data) {
    Ti.API.info("User clicked: " + JSON.stringify(data));
}

//HANDLE WHEN TEXTFIELD IS CLEARED
function handleClear(){
	//Ti.API.info("Value Cleared");
}
index.tss
"#categorySearchTextField": {
  font: { fontSize: 12 },
  color: "#545454",
  backgroundColor: "#F7f7f7",
  width: "80%",
  height: 44,
  top: 50,
    clearButtonMode : Titanium.UI.INPUT_BUTTONMODE_ONFOCUS,
    returnKeyType: Titanium.UI.RETURNKEY_SEARCH,
    zIndex: 1,
    suggestions: {
        bottom : 15,
        height: Ti.UI.SIZE,
        width: "80%",
        visible : false,
        opacity : 0,
        zIndex: 10
    }
}

Contributions to: https://github.com/TheSmiths-Widgets/ts.suggestionfield

Various UI tweaks and a few methods added

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.