Ack! No go on liftoff trying to use the effective ajaxs sortable list
example. I was badly burned. Please help me get this working if
possible this is a useful example I think
I thought using the ajax example would be easier I fixed everything I
could think of. I added to the controllers.py file the following just
like kevin said about using mochikit and scriptaculous (and I easy
installed it). Now I get no errors but the list never changes here is
as much code as I got put in.
from turbogears import controllers, expose, redirect,widgets,mochikit
from turbogears import identity,validate,validators,error_handler
from model import *
from healthcareconsensus import json
import pkg_resources
cookies = ["test 1", "test 2","test 3","test 4" ]
log = logging.getLogger("healthcareconsensus.controllers")
js_dir =
'/home/ben/healthcareconsensus/healthcareconsensus/static/javascript'
widgets.register_static_directory("ajax",js_dir)
proto = widgets.JSLink("ajax", "prototype.js")
scriptaculous_js = widgets.JSLink("ajax", "scriptaculous.js")
class Scriptaculous(widgets.Widget):
javascript = [proto, scriptaculous_js, mochikit]
scriptaculous = Scriptaculous()
...
...
...
@error_handler(game_entry_error_handler)
@expose(template="healthcareconsensus.templates.scenario")
@turbogears.validate(validators={'user' : validators.NotEmpty(),
'previousgameselector': validators.NotEmpty })
def
game_entry(self,previousgameselector=None,user=None,submit=None):
#get the game's round's order list
#select game
# gl = list(gresult)
# if len(gl) > 0:
#
global cookies
print cookies
return dict(cookies=cookies,scripty=scriptaculous)
@expose(format="json")
@validate(validators={"cookielist" : validators.JSONValidator()})
def saveorder(self, cookielist):
global cookies
print cookielist
cookies = cookielist
return dict()
In prototype.js I have this
------------------------------------
function update_server() {
var children = $("cookielist").childNodes;
var cookies = new Array(children.length);
for (var i = 0; i < children.length; i++) {
cookies[i] = children[i].firstChild.nodeValue;
}
jsoncookies = serializeJSON(cookies);
d = loadJSONDoc("saveorder?"
+ queryString({cookielist : jsoncookies}));
d.addCallback(update_done);
}
function update_done() {
showElement("saved");
window.setTimeout(function() {
new Effect.SwitchOff("saved", {queue: "end"})},
1000);
}
And in my html I have the stuff from the example
--------------------------------------------------------------------
<ul id="cookielist">
<li py:for="cookie in cookies" py:content="cookie"
id="c_${cookie}">Cookie Name Here</li>
</ul>
<script type="text/javascript" >
Sortable.create('cookielist',{ "onUpdate":
update_server });
</script>
<div id="saved" class="statusmsg">Changes saved!</div>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---