GithubHelp home page GithubHelp logo

Comments (5)

mkirsten avatar mkirsten commented on May 15, 2024

I think the problem is that expandable sections are initialized when the form is created (row 3252 in jsonform.js):

 // Initialize expandable sections, if any
  $('.expandable > div, .expandable > fieldset', formElt).hide();
  $('.expandable > legend', formElt).click(function () {
    var parent = $(this).parent();
    parent.toggleClass('expanded');
    $('> div', parent).slideToggle(100);
  });

When a new item in an array is added, such as in a tab array, this initialization is not done and hence there is no function attached to the mouse click nor is the section hidden as default. I think the solution is to add something very similar to the above but in this function (row 845 in jsonform.js):

      $('> a._jsonform-array-addmore', $nodeid).click(function (evt) {

I know too little javascript to alter the above code correctly so that it works, but I'll see what I can find out!

from jsonform.

mkirsten avatar mkirsten commented on May 15, 2024

Great - just found a way around it, I think. I'll submit a pull request later during the weekend.

from jsonform.

0xgeert avatar 0xgeert commented on May 15, 2024

Haven't looked at the code that well (so ignore at will) but this seems
elegantly solvable with 'delegate events' in jquery.
This allows to bind to elements (based on css selector) without the
elements having to exist when the bind is done. All future elements that
are added (here : the new item to a tab array) that conform to the css
seelctor are autobinded on creation.

See: http://api.jquery.com/on/ for more info.

Generally instead of:
$(".parent > .child).click(function(){});

you'd write:
$(".parent).on("click","> child", function(){});

2013/4/26 mkirsten [email protected]

Great - just found a way around it, I think. I'll submit a pull request
later during the weekend.


Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-17068938
.

from jsonform.

mkirsten avatar mkirsten commented on May 15, 2024

Ah, that sounds like exactly what we need. I couldn't get it work unfortunately and to my great disappointment, I realised that my so called fix introduces some side effects. I'll see if I can fix it and will post back here regardless.

from jsonform.

ulion avatar ulion commented on May 15, 2024

Fixed in the above mentioned commit of my branch.

from jsonform.

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.