Pankaj Mishra
Pankaj Mishra

Reputation: 20348

How to change Css class using JQuery?

I have an multi user application with basic layouts where i want to change the layout and style of the page for individual user .

I have one way in mind that to change the css at run time but if i am changing the css then it will take effect for every user and if i will refresh the page then it shows basic page again.

Help me for this problem that if i will change the css then it will take effect only for the same user. and it will not change after refresh.

Or any buddy has any other idea then please suggest me.

Upvotes: 4

Views: 1447

Answers (4)

keithm
keithm

Reputation: 2813

If you want to implement this yourself, store your user-specific styles in a dedicated store such as a database, indexed by user. At page construction time (server side) consult your database, looking up the customizations for that user, and apply the CSS you want to that page.

Alternatively there are a variety of theming applications available. These will depend on your server-side tools. For example, ASP.NET offers the Web Parts Framework.

Upvotes: 0

Elizabeth Buckwalter
Elizabeth Buckwalter

Reputation: 968

$("div#somediv").addClass("specialuserclass");

JQuery reference or have a stylesheet per user;

Upvotes: 2

devpl
devpl

Reputation: 204

You have to persist the style chosen by each user.

Your can design your function/screen to something like: 1. On create of a new user, give the user the default basic layout and persist this in the server side (you can probably save the user preference in your DB). 2. When he changes style, update the user's user preference record/file 3. On load of the page, retrieve the user preference and change the css style on the server side

Upvotes: 0

tvanfosson
tvanfosson

Reputation: 532595

You might be interested in doing this using themes and the theme manager plugin I built. The plugin is built to work with jQuery UI themes, but could easily be adapted to your own custom CSS-based themes. This plugin works with individual user preferences for a particular theme stored in a database, though I suppose you could also use a cookie. the latter would take more customization. You can find more info on my blog, http://farm-fresh-code.blogspot.com.

Upvotes: 1

Related Questions