Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

네이버와 같은 여러 판으로 구성된 사이트 내에 persist 활용문의 #43

Open
changdongchun opened this issue Sep 16, 2020 · 1 comment
Assignees

Comments

@changdongchun
Copy link

네이버와 같은 여러 판으로 구성되어있는 사이트내에서 persist를 응용하여 히스토리 BACK시에 화면 구성을 하려고 할때
HTML각각 판을 저장할 수 있는 방법이 있을까요?

@WoodNeck
Copy link
Member

WoodNeck commented Sep 16, 2020

안녕하세요.
Persist 데모 페이지 제일 아래쪽을 확인해보시면 해당 예제를 확인해보실 수 있습니다.
판마다 key만 달리하여 지정해주시면 될 것 같습니다.

const persist = new eg.Persist("commentModule");

$(".loadCmtBtn").on("click", function() {
	// Make change to the component. (append comments) 
	$.get("/api/123/nextcomment", function(commentHtml) {
		$(".commentContainer").append(commentHtml);		

		// Save snapshot of the component when there is a change
		var snapshot = $(".commentContainer").html();
		persist.set("commentsHTML", snapshot);
	});
});
	
// Restore state when initiate component
if(!persist.get("") === null) {
	var commentsHTML = persist.get("commentsHTML");
	$(".commentContainer").html(commentsHTML);
}

@WoodNeck WoodNeck self-assigned this Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants