I have a single form to allow a user to add a series of events. Each event can include dates, pictures and files. When a user clicks a button, a jQuery function clones the code for a new event and inserts it below existing events. The cloned code includes 'input/date' and 'input/dropzone' fields. The code clones fine and the form looks the way it should, but the date and picture input fields don't work. They don't accept input as they do when rendered at the time of page loading.
My Question
How should I properly duplicate datepicker and dropzone objects? I understand from other discussions that the answer may include some reference to the AMD model. If so, I would really appreciate guidance on how to implement the suggestion. I've spent many weeks following this path and have pitiful little to show for my effort.
Here is the jQuery code is use to add a new event:
$(document).ready(function() {
$(".add-progress-marker").on("click", function(e){"use strict"
e.preventDefault(); // clone the node
var line_item = $(".progress_marker_line_items").clone(true, true).contents();
var $input = $(line_item);
line_item = $input.outerHTML;
$input.insertBefore(".new_line_items").outerHTML;
}); });
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- C0Rrupt@thjMMvw
C0Rrupt - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 0 likes
- C0Rrupt@thjMMvw
C0Rrupt - 0 likes
- C0Rrupt@thjMMvw
C0Rrupt - 0 likes
You must log in to post replies.The strategy I use lately is to render everything server side and use ajax API to load the view and insert into DOM rather than trying to deal with all the cloning.
That sounds ... sophisticated. Even though it may not be the best strategy, could you help me deal with it by cloning instead? That, or perhaps show me how to render everything server side and use ajax API to load the view and insert into DOM? Either way, I need a little help to make it work. Examples would be a great help, to be sure. I'm not sophisticated enough to use directional suggestions alone. I'm certainly willing to learn and to do my research; I've been researching and trying things for months. Now, I'm sort of praying for a miracle.
Thanks. Great detail. I'll try it out.
For the sake of others, here is how I implemented your recommendation: