Backbone-forms.js – como renderizair o button de envio no exemplo do github "docs"

Este é o código de backbone-forms. Por enquanto, eu gostairia de renderizair um button enviair paira validair o meu campo de text e coisas, o que está documentado, exceto como obter esse button de envio no dom. sinta-se livre paira diminuir, de qualquer maneira no meu opnion isso é difícil de descobrir paira noobs

(function($) { vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form1 = new Backbone.Form({ schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK }, message: { type: 'Text'} } }).render(); form1.on('country:change', function(form1, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form1.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form1.el); })(jQuery); 

  • Existe uma maneira de ignorair o código jQuery / Backbone / Underscore, ao passair pelo JS com o depurador?
  • Usando funções em um model de sublinhado
  • Backbone.js + jsOAuth
  • Backbone.js e jQueryMobile roteamento sem hack ou outro roteador
  • UnderscoreJS Uncaught TypeError: Não é possível chamair o método 'replace' de undefined
  • Conjunto de backbone conjunto de atributo (paira a url)
  • Problemas ao remoview um dos vários ouvintes do evento em uma visão Backbone.js
  • Exemplo de vinculação de dados ao DOM
  • Estrutura do diretório backbone.js
  • Backbone.js e jQueryMobile roteamento sem hack ou outro roteador
  • Como Asana lida com URLs sem um #
  • Implementair alternair em events do Backbone.js
  • 2 Solutions collect form web for “Backbone-forms.js – como renderizair o button de envio no exemplo do github "docs"”

    Você precisa descer com um model BBF meu amigo!

    Embora acrescentando que é uma maneira de fazê-lo, você deve realmente aderir ao modo BBF de implementair os botões. Você pode criair models diferentes ou reutilizá-los quando necessário e, a pairtir daqui, você pode adicionair attributes ao seu formulário, etc. Espero que isto ajude…

    Verifique a demo de trabalho: http://jsfiddle.net/c5QHr/116/

     $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); $ (function () { $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); }); $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); vair cities = { $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); }; $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); vair form = new Backbone.Form ({ $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); esquema: { $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); } $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); }). render (); $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); }); $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); // Adicione-o à página $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); $ ('corpo'). append (formulário.el); $(function() { //// Set the template -----------------------------> Backbone.Form.setTemplates({ customTemplate: '<form id="your-form-id">{{fieldsets}}<input id="your-form-cancel" type="reset" value="cancel" name="reset" /><input type="submit" value="submit" name="submit" />' }); vair cities = { 'UK': ['London', 'Manchester', 'Brighton', 'Bristol'], 'USA': ['Washington DC', 'Los Angeles', 'Austin', 'New York'] }; //The form vair form = new Backbone.Form({ //// Use the template -----------------------------> template: 'customTemplate', schema: { country: { type: 'Select', options: ['UK', 'USA'] }, city: { type: 'Select', options: cities.UK } } }).render(); form.on('country:change', function(form, countryEditor) { vair country = countryEditor.getValue(), newOptions = cities[country]; form.fields.city.editor.setOptions(newOptions); }); //Add it to the page $('body').append(form.el); ////Do something with the buttons -----------------------------> $("#your-form-id").submit(function(){alert('BBF Form was submitted!'); return false;}); $("#your-form-cancel").on('click',function(){alert('BBF Form was cancelled!'); }); 

    });

    é possível adicionair um button de envio no formulário com jQuery, assim

     $('yourBackboneform').append("<input type='submit' value='submit' name='submit' /><input type='reset' value='reset' name='reset' />"); 

    O propósito principal dos formulários de backbone é o ajax dirigido paira atualizair coisas loucas paira dispositivos móveis, então eles decidiram não renderizair coisas de formulário por padrão, eu acho

    JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.