Giter Club home page Giter Club logo

jsonform's People

Contributors

abraaoalves avatar albertoleal avatar cmilfont avatar joshmosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jsonform's Issues

build correct json to input checkbox with value

Segundo MDN: https://developer.mozilla.org/En/HTML/Element/Input#attr-type

"A check box. You must use the value attribute to define the value submitted by this item. Use the checked attribute to indicate whether this item is selected. You can also use the indeterminate attribute to indicate that the checkbox is in an indeterminate state (on most platforms, this draws a horizontal line across the checkbox)."

Considerando que json retornado pelo método getJSON pode ser submetido a um serviço http, ele deve representar, de forma identica, o formulário ou inputs em questão.

Configuration to solve the type conversion

Converting types of values like that:

var byId = true,
config = {
numeric: ["value"],
date: ["date"]
}
var json = jQuery("#myform").getJSON(byId, config);
typeof json.value === "number"
Object.prototype.toString.call(json.date) === "[object Date]"

Populate to select-multiple not works

Json:
{"transacao": {"id": 240,"data": "01/08/13","valor": "111.11","fluxo": "ENTRADA","descricao": "fsdfd","conta": {"id": 2},"tags": [{"id": 1},{"id": 2}]}}

Chamada ao jsonform:

$("#form_transacao").populate(data); // data from json

Atente para a seguinte linha:
https://github.com/milfont/jsonform/blob/master/lib/jsonform.js#L142

Na primeira execução do loop, o debug mostra:

$("form#form_transacao.form-horizontal").find("[name='transacao\.tags\[\]\.id']").eq(0)

other.val(value);

E o elemento (select-multiple) é encontrado corretamente.

Mas, na segunda execução do loop, o debug mostra:

$("form#form_transacao.form-horizontal").find("[name='transacao\.tags\[\]\.id']").eq(1)

other.val(value);

Não encontra o elemento.

Não sei por que foi utilizado o .eq(index) na linha:
https://github.com/milfont/jsonform/blob/master/lib/jsonform.js#L145

Mesmo que o elemento fosse encontrado o valor do select-multiple seria substituído, não adicionado de mais um 'option' com 'selected'.

A forma correta de se atribuír um valor a um select-multiple com jquery, não seria?

$(selector).val([1,2,3])

Se executar for como abaixo, e como parece ser o comportamento do jsonform, o comportamento não seria o mesmo:

$(selector).val(1)
$(selector).val(2)
$(selector).val(3)

Bug with 0(zero) values

When you have the value = 0(zero) coming from the json, the populate does not fill the referenced input with any value, it just leaves it blank, it should bring it as 0(zero)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.