having issue with template switcher

Discussion in 'jQuery' started by shadow_boi, Jan 17, 2011.

  1. #1
    Hi all.

    I am a jquery newbie and trying to make a template switcher function.

    Here is what i have so far:http://www.sumsy.com/testing/

    If I click on "login page" or "member page" first, and then click on "Template 1" or "Template 2", it wont work.

    IE gave me "permission denied" js error. FF didnt give me error, but nothing happened.

    Is it because after we click on the login or member page, the DOM elements has changed, so it doesnt work?

    Please shred some light.

    Thanks in advanced.

    
    $(document).ready(function(){
    
    	var templateframe = $('#templateframe').contents();
    
    		noclick();
    	
    		$("#templateselect li a").click(function() { 
    		var style = $(this).attr('rel');					  
    									  
    		templateframe.find('link').eq(0).attr("href", "styles/" + style + "/_css/main.css");
    		alert(templateframe.find('link').eq(0).attr("href"));
    		return false;
    	});
    	
    		$("#pagenav li a").click(function() { 
    		var page = $(this).attr('rel');					  
    									  
    		$('#templateframe').attr("src", "template/" + page + ".html");
    		noclick();
    		return false;
    	});
    
    	
    	
    		$('#applybtn').click(function(event) {
    			var title = $('#sitetitle').val();
    
    			if(title.length > 0){
    	 			templateframe.find('.content h1').html(title);
    			}
    			
    			
    			event.preventDefault();
    
    		});
    		
    function noclick(){
    	
    	    $('#templateframe').load(function(){
            //$('#templateframe').contents().find('.content h1').html('Hey, i`ve changed content of <body>! Yay!!!');
    		$('#templateframe').contents().find('a').click(function(event) {
    
    			alert("Demo Only");
    			event.preventDefault();
    
    		});
    	    });	
    	
    	}
    	
    	
    });
    
    Code (markup):
     
    shadow_boi, Jan 17, 2011 IP