Created
December 9, 2013 15:13
-
-
Save softwarerero/7873694 to your computer and use it in GitHub Desktop.
Meteor Autoform - No update, no callback called.
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
<head> | |
<title>autoform02</title> | |
</head> | |
<body> | |
{{> consulta}} | |
</body> | |
<template name="consulta"> | |
<p>The value ruc is never updated in the db. None of the callback on autoforms is called.</p> | |
{{#autoForm schema=scheme doc=doc}} | |
{{afQuickField "ruc"}} | |
<button type="submit" class="update">Guardar</button> | |
{{/autoForm}} | |
</template> |
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
Consultas = new Meteor.Collection2("consultas", { | |
schema: { | |
ruc: { | |
type: String, | |
label: "RUC" | |
} | |
} | |
}); | |
Consultas.allow({ | |
insert: function() { | |
return true; | |
}, | |
update: function() { | |
return true; | |
}, | |
remove: function() { | |
return true; | |
}, | |
fetch: [] | |
}); | |
if (Meteor.isClient) { | |
Meteor.subscribe("consultas"); | |
ConsultasForm = new AutoForm(Consultas); | |
ConsultasForm.hooks({ | |
before: { | |
update: function(doc) { console.log("update"); return doc} | |
}, | |
after: { | |
update: function(error, template) { console.log("error on update")} | |
}, | |
onSubmit: function(error, result, template) { console.log("submit"); true} | |
}); | |
Template.consulta.helpers({ | |
scheme: function() { | |
return Consultas; | |
}, | |
doc: function() { | |
return Consultas.findOne({ ruc: "123456" }); | |
} | |
}); | |
}; | |
if (Meteor.isServer) { | |
Consultas.remove({}); | |
Consultas.insert({"ruc": "123456"}); | |
Meteor.startup(function () { | |
Meteor.publish("consultas", function() { | |
Consultas.find(); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment