SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2013
    Posts
    132
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    modal opens but do not close, i failed debug

    chapter_07/18_simple_modal_dialog/index.html
    in book
    jQ ninja 2e

    modal opens but do not close(removed), i failed debug:

    Code:
    $(document).ready(function(){
    	$('#eulaOpen').click(function() {
    		openDialog('#eula');
    	});
    
    	$('#eula').find('.ok, .cancel')
    	.on('click', function() {
    		closeDialog(this);
    	})
    	.end()
    		.find('.ok')
    		.on('click', function(){
    			// Clicked Agree!
    			console.log('clicked agree!');
    			//closeDialog(this);
    		})
    	.end()
    		.find('.cancel')
    		.on('click', function() {
    			// Clicked disagree!
    			console.log('clicked disagree!');
    			//closeDialog(this);
    		});
    });
    
    function openDialog(selector) {
    	$(selector)
    		.clone()
    		.appendTo('#overlay')
    		.show()
    		.parent()
    		.fadeIn('fast');
    }
    	
    function closeDialog(selector) {
    	$(selector)
    	.parents('#overlay')
    	.fadeOut('fast', function() {
    		$(this)
    			.find('.dialog')
    			.remove();
    	});
    }

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,358
    Mentioned
    179 Post(s)
    Tagged
    9 Thread(s)
    Try this:

    Code JavaScript:
    $(document).ready(function(){
    	$('#eulaOpen').click(function() {
    		openDialog('#eula');
    	});
     
    	$('#container').on('click', '.ok, .cancel', function() {
    		closeDialog(this);
    		console.log("You clicked: " + $(this).text());
    	})
    });
     
    function openDialog(selector) {
    	$(selector)
    		.clone()
    		.appendTo('#overlay')
    		.show()
    		.parent()
    		.fadeIn('fast');
    }
     
    function closeDialog(selector) {
    	$(selector)
    	.parents('#overlay')
    	.fadeOut('fast', function() {
    		$(this)
    			.find('.dialog')
    			.remove();
    	});
    }

  3. #3
    SitePoint Zealot
    Join Date
    May 2013
    Posts
    132
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    worked thks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •