I was using StringCol instead of UnicodeCol. I'm really sorry with all of you

but now I've run into another problem. I have a multipleselect that
has an element at the end (add person) that when clicked pops up a JS
prompt to ask a name, and adds that name to my database, and on
success, adds the name to the multipleselect in my form. The problem
is that when the person already exists an exception is (obviously)
thrown, and the callback of loadJSONDoc is called only one more time.
After that I'm not able to insert more elements, nor do stuff like
reload my page. when I do that, the browsers waits and does nothing.

to put things in context, I'll paste the code.
First, the controller:
@tg.expose(format="json")
  def addPerson(self,name):
    try:
      person=m.Person(name=name)
    except Exception:
      return dict(errors=u"That person already exist")
    return dict(id=person.id,name=person.name)

and now the JS stuff

function addPerson(name) {
  var name = prompt("Add Person","Name")
  if (name==null) {
    return //the user hits cancel
  }
  d=loadJSONDoc("./addPerson?tg_format=json&name="+name)
  d.addCallback(dos)
}

function dos (d) {
  if (d["tg_errors"]) {
    alert(d["tg_errors"])
    return
  }
  alert("hola!!!")
  select = document.getElementsByName("persons")[0]
  last = select.options[select.options.length-1]
  removeElement(last)
  appendChildNodes(select, OPTION({"value":d["id"]},d["nombre"]),last)
}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to