I have looked though the forum and have not been able to find a solution to my specific problem. I am creating an element from a modal popup window. I can get it to display on the page but its not clickable.
I have jquery code running in two separate files to be able to do what I need for the application.
What happens is I have an "edit" icon that gets loaded onto each element at load. This works fine and when you click it creates the modal box and loads "page 2". All of the functionality inside there works properly. When the user clicks "update" the box closes and fires the "append_elements" function from "page 1" and loads up the new icon. However this edit icon that was just added doesn't click.
I have tried using on() in various places but have not had any luck getting it to work.
Thanks Eric
Page 1:
$(document).ready(function(){
append_elements();
$('.cms_edit').on('click', function(){
var maskHeight = $(document).height();
var maskWidth = $(window).width();
$('#mask_temp').css({'width':maskWidth,'height':maskHeight});
$('#mask_temp').fadeIn(1000);
var winH = $(window).height();
var winW = $(window).width();
var content_object = { 'content' : $(this).parent().html(), 'item_id' : $(this).parent().data("item") }
$('#modal_temp').load('/content-edit.php', content_object);
$('#modal_temp').css('top', winH/2-$("#modal_temp").height()/2);
$('#modal_temp').css('left', winW/2-$("#modal_temp").width()/2);
$('#modal_temp').fadeIn(500);
});
});
function append_elements()
{
$('.cms_edit').appendTo('.editable').show();
}
Page 2:
$('#update').click(function(){
var value = CKEDITOR.instances['page_text'].getData();
var item = $('#prev_id').val();
var elem = '<div class="cms_edit"><em class="icon-edit"></em></div>';
$('#item_' + item , parent.document).html(value);
$('#modal_temp', parent.document).fadeOut(500);
$('#mask_temp', parent.document).fadeOut(500);
parent.append_elements();
});