Reputation: 41
I have one div#logo. i set background image for this div. I change image dynamically using jQuery. and one common page which contain div#logo. i have one button from UI side which change the background image of div#logo.but when i redirect to another page div#logo page take default background image.
What i have to for all page which i select image form UI side button.
Upvotes: 1
Views: 583
Reputation: 25279
Without persistent storage on the server side (and all the troubles arising from it like input validation etc.) I'd argue that you are best of storing the user's choice in a cookie.
Since you are using jQuery you could make use of the jQuery Cookie plugin.
$(function() {
var img = $.cookie('background') || 'standard-bg.png';
$('#logo').css({
backgroundImage: img
});
$('button').click(function() {
var img_src = $(this)... // However you determine the particular image
$('#logo').css({
backgroundImage: img_src
});
$.cookie('background', img_src);
});
});
Upvotes: 1
Reputation: 836
Store the background image url to SESSION
.
And update this variable via ajax
call on change of background image.
That way you will be able to get selected background image on all other pages.
EDIT:
OR
You can try javsacript session.
Persist javascript variables across pages?
Upvotes: 0