Comments (8)
What code exactly did you copy paste? Since it works in the test app I assume something went wrong there.
from nl.fokkezb.form.
Ahh i have copied the test app
https://github.com/FokkeZB/nl.fokkezb.form/tree/test/app
I think this must be out of date?
I copied the code from the index.xml and index.js.
When i copied the test from the widget example it works ok.
How do i implement this using Alloy view rather than in the controller?
from nl.fokkezb.form.
You first say you copied the test app and then you say you copied only index.xml
and index.js
. Which of the two is it?
I just ran the test app with 4.0.0.RC
and it works fine for me.
The Getting Started has examples of all different ways to init the form.
from nl.fokkezb.form.
I think its when i use:
section: {
footerTitle: 'footerTitle of section set in JS',
rows: [$.sectionRow]
},
and
<TableViewRow id="sectionRow" title="Custom row via section" />
It seems to crash the app.
Im not sure if its due to the alloy TableViewRow being outside of the window?
from nl.fokkezb.form.
That shouldn't be a problem. If you run the test app as-is using the instructions here you get the same error? What OS/SDK?
from nl.fokkezb.form.
Im installing the widget using Gittio.
When i view the widget I'm seeing different (older) code to whats the in the test app?
When I'm running your test app (installing the widget using Gittio) i get an error:
[ERROR] : Script Error {
[ERROR] : column = 17;
[ERROR] : line = 118;
[ERROR] : message = "Can't find variable: onUnsetClick";
[ERROR] : sourceURL = "../alloy/widgets/nl.fokkezb.form/controllers/picker.js";"
When i check the file picker.js there is no onUnsetClick function.
But in your test app there is!
https://github.com/FokkeZB/nl.fokkezb.form/blob/2bc8a2680dcbc33ecc438ac22208370a655862f7/controllers/picker.js
It appears the Gittio install has a different code in the widget?
from nl.fokkezb.form.
My widget says I'm running 1.6.1
But my picker.js is missing the onUnsetClick function:
/**
* Controller for the date/time picker field type.
*
* The date/picker picker field type is a `Ti.UI.Label` to display current and a `Ti.UI.Picker` to change the value.
*
* *WARNING:* Only support iOS and Android date/time for now.
*
* @class Widgets.nlFokkezbForm.controllers.picker
* @extends Widgets.nlFokkezbForm.controllers.field
* @xtype picker
*/
var moment = require('alloy/moment');
exports.baseController = '../widgets/nl.fokkezb.form/controllers/field';
$.focus = focus;
$.setValue = setValue;
$.getValue = getValue;
var m;
var table;
var pickerShowing = false;
var picker = {
type: Ti.UI.PICKER_TYPE_DATE,
valueFormat: 'YYYY-MM-DD'
};
/**
* Constructor.
*
* @constructor
* @method Controller
* @param args Arguments which will also be used to call {@link Widgets.nlFokkezbForm.controllers.field#Controller}.
* @param {Object} [args.input] Properties to apply to the `Ti.UI.Label`.
* @param {Object} [args.picker] Properties to apply to the `Ti.UI.Picker`.
* @param {Number} [args.picker.type=Ti.UI.PICKER_TYPE_DATE] On Android, if this is `Ti.UI.PICKER_TYPE_DATE` or `Ti.UI.PICKER_TYPE_TIME` this will trigger the related dialogs.
* @param {String} [args.picker.valueFormat="YYYY-MM-DD"] Format in which the value is set and get.
* @param {String} [args.picker.textFormat] Format in which the value is displayed (defaults to `valueFormat`).
* @param {String|Object} args.label Will be used for the popover title as well.
*/
(function constructor(args) {
// save a reference to the table
table = args.form.table;
// extend picker defaults
picker = _.extend(picker, args.picker || {});
$.picker.applyProperties(picker);
// display a hasChild marker
$.row.applyProperties($.createStyle({
classes: ['row']
}));
// input properties to apply
if (args.input) {
$.input.applyProperties(args.input);
}
// add the input to the row
$.setInput($.input);
// compose view
if (Ti.Platform.osname === 'ipad') {
$.popover.title = $.label.text;
$.popover.add($.picker);
}
})(arguments[0]);
/**
* Displays an option dialog to change value.
*
* This method is called by {@link Widgets.nlFokkezbForm.controllers.widget} when the user clicks on the row.
*/
function focus(e) {
var date;
if (m) {
// picker needs a year, also for time
if (m.year() === 0) {
date = moment(m).year(2000).toDate();
} else {
date = m.toDate();
}
}
$.picker.value = date;
if (OS_IOS) {
if (Ti.Platform.osname === 'ipad') {
$.popover.show({
view: $.input
});
} else {
// Wrap the picker in a row
$.pickerRow.add($.picker);
// Update the label on change
$.picker.addEventListener('change', function(e) {
onDialogClose({
value: $.picker.value
});
});
// Check if showing the picker row already
if (pickerShowing === false) {
//Insert row
table.insertRowAfter(e.index, $.pickerRow, {
animationStyle: Titanium.UI.iPhone.RowAnimationStyle.DOWN
});
pickerShowing = true;
} else if (pickerShowing === true) {
// Delete row
table.deleteRow(e.index + 1, {
animationStyle: Titanium.UI.iPhone.RowAnimationStyle.UP
});
pickerShowing = false;
// Update the value on close of row
onDialogClose({
value: $.picker.value
});
}
}
} else if (OS_ANDROID && picker.type === Ti.UI.PICKER_TYPE_DATE) {
$.picker.showDatePickerDialog({
cancel: onDialogClose
});
} else if (OS_ANDROID && picker.type === Ti.UI.PICKER_TYPE_TIME) {
$.picker.showTimePickerDialog({
cancel: onDialogClose
});
} else {
throw 'Only support iOS and Android date/time for now.';
}
}
function setValue(value) {
var mom = moment(value, (typeof value === 'string') ? picker.valueFormat : undefined);
if (!mom) {
console.error('Invalid value: ' + JSON.stringify(value));
return;
}
m = mom;
$.input.text = m.format(picker.textFormat || picker.valueFormat);
}
function getValue() {
return m ? m.format(picker.valueFormat) : null;
}
function onDoneClick(e) {
onDialogClose({
value: $.picker.value
});
onCancelClick(e);
}
function onCancelClick(e) {
$.popover.hide();
}
function onDialogClose(e) {
if (!e.cancel) {
$.setValue(e.value);
$.change();
}
}
from nl.fokkezb.form.
It was fixed in master but not yet in 1.6.1
Just published 1.6.2 with this fix.
from nl.fokkezb.form.
Related Issues (20)
- Type 'select' doesn`t work HOT 5
- Multiple select types, shows the last select options for all select type fields HOT 2
- [NEW] Auto focus on next field HOT 2
- More Android issues HOT 5
- [DOC] Fix type code example HOT 1
- Time picker, appear in the behind current window HOT 1
- Bad implementation for horizontal layout rows HOT 1
- [NEW]: Allow select field to accept function HOT 1
- [NEW] Allow passing HeaderView & FooterView from xml
- Weird scrolling behaviour HOT 2
- basecontroller not working after upgrade to SDK 6.0.0.GA HOT 7
- ListView input type HOT 2
- Media input type HOT 1
- Barcode scanner input type HOT 3
- Signature input type HOT 1
- RTL Support HOT 1
- Material theme
- Pass error handler
- Picker.js HOT 3
- Reset Form Fields to Default after submit HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nl.fokkezb.form.