Welcome Guest, Not a member yet? Register   Sign In
[Solved] Codeigniter JQUERY
#1

(This post was last modified: 11-20-2016, 06:00 PM by wolfgang1983.)

On my codeigniter project, the user can insert a image by url or upload it per normal.

I generate some text using jquery html()


Code:
<script type="text/javascript">
standardhtml = '';
standardhtml += '<div class="" style="display: block;">';
standardhtml += 'You can also provide a ';
standardhtml += '<a class="url_input">link from the web</a>';
standardhtml += '</div>';

$('.hyperlink_text').html(standardhtml);

$(".hyperlink_text a.url_input").click(function(){
    newhtml = '';
    newhtml += 'Link from the web ';
    newhtml += '<input class="form-control input-sm" placeholder="http://example.com/image.png" type="text">';
    newhtml += '<span class="separator"> | </span>';
    newhtml += '<a class="cancel" id="cancel">Cancel</a>';
    $('.hyperlink_text').html(newhtml);
});

// Should be able to detect cancel button above does not?

$("a.cancel").click(function(){
    $('.hyperlink_text').html(standardhtml);
    alert('Yes Works'); // Does not work
});
</script>


When I click on a.url_input link it generates new html in that html it has a cancel a tag in it

When I click on the cancel tag it should re generate the (standardhtml) but does not it is not detecting the a.cancel link

Code:
$('.hyperlink_text').html(standardhtml);

Example Codepen  Demo

Question How can I make sure when I click on cancel button on the newhtml it will regenerate the standardhtml
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Codeigniter JQUERY - by wolfgang1983 - 11-19-2016, 11:18 PM
RE: Codeigniter JQUERY - by Wouter60 - 11-20-2016, 12:51 AM
RE: Codeigniter JQUERY - by wolfgang1983 - 11-20-2016, 01:18 AM
RE: Codeigniter JQUERY - by Paradinight - 11-20-2016, 11:01 AM
RE: Codeigniter JQUERY - by wolfgang1983 - 11-20-2016, 05:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB