Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to make an editor everything working fine till now, but now I need to make a handler which could detect any change made in a div or any content edited in the div

<?php $row="testing content" ?>
<!-- my editor section-->
<div id="editor">
    <div id="options">
        <span><a id="iimg">Insert Image from gallery</a></span>
        <span>Upload image to gallery</span>
        <span><a id="iheading">Heading</a></span>
    </div>
    <div id="product_descriptioncontent" contenteditable="true"><?php echo $row; ?>
    </div><!-- viewable editor -->
    <input type="hidden" name="textareacontent" value="" id="textareacontent" >
    <!-- hidden field to submit values -->
</div>
<!-- end of editor section -->
<div id="imc"></div> <!-- image gallery loading section -->

<script>
$(document).ready(function(){

    $('#iheading').click(function(){
    $('#product_descriptioncontent').append('<h1>Heading</h1>');
    });

    $('#iimg').click(function(){
        $('#imc').load('imagegallery.php',function(){
        $('#gallery img').on('click',function(){
            $('#product_descriptioncontent').append('<img  src="http://localhost/sites/site_pics/otherpic/1.png"><br>&nbsp;');
    });
    });
    });
    $('#product_descriptioncontent').change(function(){
    alert("pppp");// how to capture this event
    });
});
</script>

I have placed a bit of my code at jsfiddle http://jsfiddle.net/bipin000/UJvxM/1/ thanks for your precious time

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
173 views
Welcome To Ask or Share your Answers For Others

1 Answer

Try adding a handler for DOMCharacterDataModified. Might be a cleaner solution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...