Giter Site home page Giter Site logo

Comments (10)

ryanb avatar ryanb commented on July 30, 2024

Good idea, I'll mark this to be added to the docs. If anyone wants to do this feel free to submit a pull request.

from nested_form.

oli-g avatar oli-g commented on July 30, 2024

+1

How to access the added fields infos from the nested:fieldAdded event?

$("form").live("nested:fieldAdded", function(event) {
        console.log(event.type);
        console.log(event.field);
        console.log(event.data);
});

event.data and event.field are undefined...

from nested_form.

oli-g avatar oli-g commented on July 30, 2024

event.field was undefined because I was using the rubygems code. The master branch version insted has the event.field object. Sorry about that! I will submit a pull request for documenting this as soon as I can.

from nested_form.

cmezak avatar cmezak commented on July 30, 2024

I'd really appreciate some documentation here, because I can't seem to get it working. oll-g's code won't even trigger an alert for me.

from nested_form.

virtualfunction avatar virtualfunction commented on July 30, 2024

I found I've had to change the code in jquery_nested_form.js from:

$(link).closest("form").trigger({ type: 'nested:fieldRemoved', field: field });

to:

$(link).closest("form").trigger('nested:fieldRemoved', { field: field });

It looks like the efvent wasn't being triggered, I'm guessing that in newer versions of jQuery ryan's using of the 'type' field is no longer supported.

from nested_form.

rverstappen avatar rverstappen commented on July 30, 2024

FYI: It seems to work as advertised to me without any changes, assuming event.data is OK as undefined.

from nested_form.

lest avatar lest commented on July 30, 2024

@virtualfunction the latest jquery version supports this style of event triggering (see "Alternative way to pass data through an event object" example in the documetation)

from nested_form.

iwan avatar iwan commented on July 30, 2024
$(document).on("nested:fieldAdded", ".my_selector", function() {
   alert("Field added!");
});

from nested_form.

lest avatar lest commented on July 30, 2024

@iwan Could you please make a pull request with this example?

from nested_form.

lest avatar lest commented on July 30, 2024

JavaScript events section was added to README.

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.