Trouble getting Ember Validations to work - validation

Since Ember doesn't support form validation out of the box (as of this writing anyway), I am looking for a way to validate forms. I came across Dockyards ember-validations and the consensus seems to be that this is the goto module for form validation in EmberJS.
I'm trying to get it to work, but I'm having some trouble getting started.
I'm not using Ember CLI as referenced in the docs, so I have downloaded a compiled ember-validations.js from http://builds.dockyard.com/ and have included ember-validations.js in my apps js file.
The docs now say to pass the validations.mixin into a controller:
So I'm using:
App.MemberaddController = App.FamilyController.extend(EmberValidations.Mixin,{
needs: ["family","notifications"],
familyController: Em.computed.alias('controllers.family'),
notifications: Em.computed.alias('controllers.notifications'),
validations: {
firstname: {
presence: true,
presence : {message: 'mag niet leeg zijn'}
}
},
init: function() {
this.set('familyController.pageTitle', "Gezinslid toevoegen");
},
<etc...>
}
However in the browser I'm seeing
Uncaught ReferenceError: EmberValidations is not defined
Looking at the ember-validations.js I can see the mixin file being referenced as Ember.Validations.Mixin.
So when I pass that to my controller, like
App.MemberaddController = App.FamilyController.extend(Ember.Validations.Mixin,{
I'm seeing:
Error while processing route: memberadd Cannot read property 'invoke' of undefined TypeError: Cannot read property 'invoke' of undefined
In the ember-validations.js file at the _validate function.
What am I doing wrong here?

First on the off chance this is a new project and you have the option to use ember-cli I recommend you do so, the community is moving in that direction.
That said I think your bug is in here
validations: {
firstname: {
presence: true, <-- uneeded
presence <-- remove this space: {message: 'mag niet leeg zijn'}
}
},
should look like this
validations: {
firstname: {
presence: {message: 'mag niet leeg zijn'}
}
},

Related

how to create custom validators in Angular 2 ES5?

I'm trying to create a custom validator for Angular 2 using ES5. I can't find a sample online, and the cheatsheet of the documentation doesn't help and it's not documented for ES5 at all. Also, I can't transpile completely from given examples of TypeScript to ES5. Let's say the validator is a simple code validator that more than a simple Regular Expression match, should check for CRC too. Thus it can't be accomplished with built-in pattern validator of Angular 2.
Here's my code that I've tried:
var securityCode = ng.core.Directive({
selector: '[securityCode][ngModel]',
providers: [
{
provide: ng.forms.NG_VALIDATORS,
useExisting: securityCode,
multi: true
}
]
}).Class({
constructor: function() {
console.log('securityCode');
},
validate: function(value){
console.log('validate...');
},
validator: function(value){
console.log('validator...');
}
});
and here's how I want to use it:
<input mdInput type="text" requried securityCode />
I'm stuck now, I can't go further as this doesn't work because I get Cannot read property 'validate' of undefined exception, and I have no idea what to do next.

SAPUI5 - FilterBar - setVisible not working

I'm using sap.ui.comp.filterbar.FilterBar Control on a project. Everything works fine, except when I try to hide this Control.
var oFilterBar = new sap.ui.comp.filterbar.FilterBar("filterBar",{
reset: oController.handleOnReset,
search: oController.handleOnSearch,
showRestoreOnFB: true,
showClearOnFB: true,
showRestoreButton: true,
showClearButton: true,
...
});
oFilterBar.setVisible(false);
I'm getting the following error:
Uncaught TypeError: oFilterBar.setVisible is not a function
Since this property is being inherited from sap.ui.core.Control class, this should work and I think it has nothing to do with versions either (I'm using 1.24).
It has something to do with the version.
In SAPUI5 1.28[1] the property visible was moved to sap.ui.core.Control so any Control extending it would have this property as well.
If you are using an earlier version only Control that implement this property themselves can be made invisible.
You could however extend the control you are using to include this property:
sap.ui.comp.filterbar.FilterBar.extend("my.FilterBar", {
metadata: {
properties: {
visible: {
type: "boolean",
group: "Appearance"
}
}
},
renderer: function (oRm, oControl) {
if (oControl.getVisible()) {
sap.ui.comp.filterbar.FilterBarRenderer.render(oRm, oControl);
} else {
// Handle invisibility
}
}
});

Uncaught TypeError: Cannot read property 'push' of undefined

Version 2.0.0
I'm trying to use the parse object as per the docs: https://trigger.io/modules/parse/current/docs/index.html
forge.parse.push.subscribe(...)
The error I am getting: Uncaught TypeError: Cannot read property 'push' of undefined which. So the parse property is not set. I have heard that this is a problem where the config is not set correctly, but setting parse up via the toolkit doesn't seem to have any effect and the parse property is still not set.
My config:
{
...
"modules": {
...
"parse": {
"version": "2.0",
"config": {
"clientKey": "xxx",
"applicationId": "xxx"
}
}
...
}
...
}
Forge signature:
{
button: Object
config: Object
document: Object
enableDebug: function (){h.debug=true;h.priv.call("internal.showDebugWarning", },null,null);h.priv.call("internal.hideDebugWarning",{},null,null)}
event: Object
file: Object
geolocation: Object
internal: Object
is: Object
logging: Object
message: Object
notification: Object
prefs: Object
reload: Object
request: Object
tabs: Object
tools: Object
__proto__: Object
}
It looks like you're trying to use Parse on a non-mobile target (probably web). Parse push notifications are only available on Android and iOS.
Try below.
forge.partners.parse.push.subscribe("offers",
function () {
forge.logging.info("subscribed to offers push notifications!");
},
function (err) {
forge.logging.error("error subscribing to offers notifications: "+
JSON.stringify(err));
});

Deployment Error with Sencha SDK Tool

I'm trying to deploy my extJS-Application, which is in MVC-Architecture style.
As described in the extJS Docs I've first tried to generate a JSB3 File with sencha create jsb -a index.html -p app.jsb3.
Sadly I've got the following error: undefined:0 TypeError: 'null' is not a constructor
I'm working on MAC OS X with Sencha Command v1.2.2.
Thanks for any help!
got the same error. On windows 7. Ext 4.0.2. Not sure how to troubleshoot this.
make sure that you include ext-dev.js in your app and you don't have any warnings/errors in Firebug/WebInspector.
Also check this thread: [SDKTOOLS-3] buggy Sencha SDK Tools
Two days ago I was suffering such type of problem. Due to my absent mind I forgot to requires some of Ext or Ext.ux class. So think some of your Extjs Class may be missing. just requires it as I pointed or add these library to your Controller/Viewport/View/Store.
Ext.Loader.setConfig({
enabled : enabled
});
Ext.Loader.setPath('Your.ns', 'app');
Ext.Loader.setPath('Ext.ux', 'ux');
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.ModelMgr.*',
'Ext.panel.Panel',
'Ext.button.Button',
'Ext.window.Window',
'Ext.toolbar.TextItem',
'Ext.menu.Menu',
'Ext.toolbar.Spacer',
'Ext.button.Split',
'Ext.form.field.TextArea',
'Ext.toolbar.Paging',
'Ext.ModelManager',
'Ext.tip.QuickTipManager',
'Ext.tree.Column',
'Ext.tree.Panel',
'Ext.tree.View',
'Ext.Loader',
//..........................................
// --Your Missing require library add here--
//................................... ......
'Ext.ux.grid.RowEditor',
'Ext.ux.data.PagingMemoryProxy',
'Ext.ux.PreviewPlugin',
'Ext.ux.ProgressBarPager',
'Ext.ux.statusbar.StatusBar',
]);
Ext.application({
name : 'Your.ns',
appFolder : 'app',
controllers : ['Your controllers'],
models : ['Your models'],
stores : ['Your stores'],
views : ['Your views'],
launch : function() {
//TODO
},
autoCreateViewport: true
});
or add your missing class in requires array
Ext.define('Your.ns.controller.YourController', {
extend : 'Ext.app.Controller',
requires : ['your required class1 here', 'your required class2 here'],
views : [],
refs : [{
ref : '',
selector : 'window'
}],
init : function() {
this.control({
// your action
});
},
//your code here
});
I think this code may be helpful.

Attaching multiple views to a controller in ExtJS 4 MVC

This is using the standard ExtJS 4 MVC library and structure.
I am trying to attach multiple views to a single controller so I can create instances of them later to add to panels. Unfortunately I am getting errors about the view when I add the second one and ExtJS is blocking the syntax errors it appears so that I am unable to see where the issue is.
If I comment out ViewOrders from the list below it works fine, but if it is in there then I get the following error:
An uncaught error was raised with the following data: ext-all-debug-with-comments.js (line 7864)
msg:
"The following classes are not declared even if their files have been loaded: 'PVAL_App.view.ViewOrders'. Please check the source code of their corresponding files for possible typos: 'app/view/ViewOrders.js'"
sourceClass: "Ext.Loader"
sourceMethod: "onFileLoaded"
Here is my controller:
Ext.define('PVAL_App.controller.Viewport', {
extend: 'Ext.app.Controller',
views: [
'Viewport', 'ViewOrders'
],
init: function() {
console.log('Viewport controller init()');
}
});
Here is my ViewOrders view:
Ext.define('PVAL_APP.view.ViewOrder', {
/* Begin Definitions */
extend: 'Ext.panel.Panel',
alias: 'widget.ViewOrders',
requires: [
'Ext.panel.Panel',
'Ext.data.ArrayStore'
],
border:false,
layout: 'fit',
//autoScroll: true,
initComponent: function() {
}
});
I doubt this is needed but this is my application file:
Ext.Loader.setConfig(
{
enabled: true
});
Ext.application({
name: 'PVAL_App',
appFolder: 'app',
autoCreateViewport: true,
controllers: [
'PVAL_App', 'Viewport'
],
launch:function() {
// Nothing yet.
//console.log(this.controllers);
}
});
I cannot seem to figure out if it is a syntax error or if this is an issue with the framework. I have experienced close to the same issue if I try to link to another controller from within one which makes me believe that this might be a constraint of the framework.
The problem here is that the class name in your app/view/ViewOrders.js script does not match the view name. Instead of Ext.define('PVAL_APP.view.ViewOrder', { you need the plural (and correct case) Ext.define('PVAL_App.view.ViewOrders', {. Either that our you can change your filename and refernece to the singular and just correct the case.

Resources