mardi 1 novembre 2016

click on link then page data come in body, url change and chat window not go out

Greeting of the Morning !

I am working a web application in which, left side bar and body, has chat module like facebook. My problem is when click on any link of the left side bar then page refresh then chat gone. I tried then show page without redirecting and change url but ping chat gone. I have used nodejs for the chat.

I do want click on link then page data come in body, url change and chat window not go out.

routes.php

Route::get('/geturl', function(){
return view('geturl');
});

geturl.blade.php

<script src="http://ift.tt/2eBd7UN"></script>

<script type="text/javascript">

$(function(){
$("a[rel='tab']").click(function(e){
//code for the link action
return false;
});
});

$(function(){
$("a[rel='tab']").click(function(e){
//e.preventDefault();


//get the link location that was clicked
pageurl = $(this).attr('href');

//to get the ajax content and display in div with id 'content'
$.ajax({url:pageurl+'?rel=tab',success: function(data){
$('#content').html(data);

}});

//to change the browser URL to the given link location
if(pageurl!=window.location){
window.history.pushState({path:pageurl},'',pageurl);
}
//stop refreshing to the page given in
return false;
});
});



/* the below code is to override back button to get the ajax content without page reload*/
$(window).bind('popstate', function() {
$.ajax({url:location.pathname+'?rel=tab',success: function(data){
$('#content').html(data);
}});
});
</script>

<body><div id="menu">
<a href="/dashboard" rel="tab">menu1</a> |
<a href="/profile/edit" rel="tab">menu2</a> |
<a href="/contact-support" rel="tab">menu3</a>
</div><div id="content"></div></body>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire