jQuery on load of dynamic element

You can trigger a custom event on the newly added DOM element that can be picked-up by a jQuery event handler: //bind to our custom event for the `.sub-element` elements $(‘#container’).on(‘custom-update’, ‘.sub-element’, function(){ $(this).html(‘<b>yaay!</b>’); }); //append a new element to the container, //then select it, based on the knowledge that it is the last child … Read more

Getting Error “Form submission canceled because the form is not connected”

Quick answer : append the form to the body. document.body.appendChild(form); Or, if you’re using jQuery as above: $(document.body).append(form); Details : According to the HTML standards, if the form is not associated to the browsing context(document), the form submission will be aborted. HTML SPEC see 4.10.21.3.2 In Chrome 56, this spec was applied. Chrome code diff … Read more

Turning live() into on() in jQuery

The on documentation states (in bold ;)): Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to .on(). Equivalent to .live() would be something like $(document.body).on(‘change’, ‘select[name^=”income_type_”]’, function() { alert($(this).val()); }); Although it is better if you bind the event … Read more