Created
March 28, 2016 16:06
-
-
Save gabouh/18112b3326cd0e02a8ab to your computer and use it in GitHub Desktop.
SearchBar implementation - Not working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model.set("searchVisible", false); | |
Model.searchShow = function() { | |
this.set("searchVisible", true); | |
}; | |
Model.searchHide = function() { | |
this.set("searchVisible", false); | |
}; | |
// I'm using a definedProperty for a specific reason -- if you don't need a event you can attach to fired per character inserted into the search bar | |
// Then just doing a Model.set("searchValue", ""); is all you need rather than the code below. | |
Object.defineProperty(Model, "searchValue", { | |
get: function () { | |
return this._searchValue; | |
}, | |
set: function (v) { | |
if (this._searchValue !== v) { | |
this._searchValue = v; | |
this.notify({ object: this, eventName: "searchValue_changed", propertyName: "searchValue", value: v }); | |
} | |
}, | |
enumerable: true, | |
configurable: true | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Model = require("../../shared/view-models/home-view-model"); | |
var bindingContext = new Observable.Observable({ | |
title: 'Home', | |
myItems: new ObservableArray.ObservableArray([]) | |
}); | |
exports.loaded = function(args) { | |
var page = args.object; | |
page.bindingContext = { bindingContext:bindingContext }; | |
}; | |
exports.searchHide = function() { | |
Model.searchHide(); | |
}; | |
exports.searchSubmit = function() { | |
Model.searchHide(); | |
console.error("Search Value:", Model.searchValue); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<page loaded="loaded" xmlns:drawer="nativescript-telerik-ui/sidedrawer" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:gv="nativescript-grid-view"> | |
<SearchBar textFieldHintColor="#ffffff" hint="Search..." text="{{ searchValue }}" col="1" colSpan="2" visibility="{{ searchVisible ? 'visible' : 'collapsed' }}" submit="searchSubmit" clear="searchHide" cssClass="mainSearch"/> | |
</page> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment