Giter Site home page Giter Site logo

Comments (4)

hzamani avatar hzamani commented on July 30, 2024

if we remove .fields the _destroy input will be removed and no destruction will happen.
I don't know replacing with _destroy is good or not, but simply setting the hidden filed values to empty may work,
just after $(this).closest('.fields').hide(); add this:
$(this).closest('.fields').find(":input:hidden").each(function() { $(this).val(""); });

from nested_form.

eostrom avatar eostrom commented on July 30, 2024

It seems like that has the reverse of the desired effect: It nullifies the _destroy input (so the item won't be deleted), but leaves the other fields intact (so client_side_validations will flag invalid input, even though it's supposed to be deleted).

from nested_form.

hzamani avatar hzamani commented on July 30, 2024

I made a mistake here, and you are right. I don't think there is a reason by not to remove that elements, because there is no way to access fields after hiding them (at least for now). And for this problem it's enough (and also more easy) to only remove the inputs from form and hide the rest, by putting:

`````` $(this).closest('.fields').find(":input:visible").remove();before$(this).closest('.fields').hide();```.

from nested_form.

lest avatar lest commented on July 30, 2024

You could use javascript events to perform any custom actions when fields are either added or removed.

from nested_form.

Related Issues (20)

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.