问题
I will be using jQuery's functionality to create portlet widgets for my web application suit. I haven't started as of yet, but will do soon, so this is the planning
Now, currently, the page loads, and the widgets load into their default positions. A user can move them around, change their settings, whatever.
Now, my problem is that I want it such that the widget placement is saved for the user, not just per session, but as an account variable.
I am using PHP and MySQL for the level-base coding and I really have no clue where to start.
Please help me :)
回答1:
The general plan would be to do something like this
in jQuery
on widget drop ajax POST to /widget.php with position info(maybe container name + item index) ('leftBar',3), maybe account # that is specific to user, as well as the identifier for the module
$.post("widget.php", { module: "myInfoModule", container: 'leftBar', ...},
function(data){
// maybe update UI telling them it's saved? probably not
}, "json");
in PHP /widget.php
read data and save information to mySQL in some schema like this
[user_id] [module_id] [container] [position]
1 'myInfoModule' 'leftBar' 3
Then, when you reload the dockable page you would read these values and put them in the order specified by the database.
Hope this gets you started
来源:https://stackoverflow.com/questions/1034360/how-to-save-portlet-positions