andrei schrieb:
> Is there a possibility to achieve the same edit in place functionality
> as in http://tool-man.org/examples/edit-in-place.html
> with Mochikit?
Yes. I do that often, the code is still a mess of globals and stuff ...
but:
var markclr= null;
var remcnblr= null;
var remcnchg = null; // den identifier des connectens
var remkeyd = null; // den identifier des OnKey
var edi=null; // der Editor
var aktivele=null;
function _editele(aktivele)
{
var mulsel=false;
var eid="e."+aktivele.id;
var b=TEXTAREA({"style":{"width":"100%","height":h+"px"},
"id":eid,
"class":"p2interaktedit"
},txt)
try {edi=swapDOM(aktivele,b);}
catch (e) {if (e!="TypeError: parent has no properties") log("neuer
fehler |"+e);
}
remcnchg =connect(edi, 'onblur', partial(leave,aktivele));
remkeyd =connect(edi, 'onkeydown', partial(function(aktivele,e){if
(e.key().string=='KEY_ESCAPE') {return leave(aktivele,e);}},aktivele));
var elmntid;
elmntid=getNodeAttribute(aktivele, 'id');
edi.focus();
return edi;
}
function che(aktivele, id, e){
log ("chewhatever aktivele etc "+aktivele+" "+ id);
var newtxt=e.target().value;
aktivele.innerHTML=newtxt;
mrkclr=Color.fromBackground('content');
}
function leave(aktivele,e){
disconnect(remcnblr);
disconnect(remcnchg);
disconnect(remkeyd);
try {var nixda=swapDOM(edi, aktivele);}
catch (e) {if (e!="TypeError: parent has no properties") log("neuer
fehler |"+e); //else log("wie immer");
}
}
################
instructions:
_editele(aktivele) has to be called to activate the "edit in place" (I
connected it to the "onclick" event of editable elements.
in my version I do something with the newly entered text (push it to
the server); I deleted that from the example, cause it needs some
dependecies serverside (of course :) )
To have a rough abstract:
1.) find an event to trigger the "in place edit", I recommend click or
doubleclick on the DOM-element
2.) create a TEXTAREA with appropriate size via the MochiKit.DOM
methods or those partials TEXTAREA(...)
3.) swapDOM your textarea with the element-to-edit-in-place
4.) bind the "onblur" and "onchanged" events accordingly
5.) deal with leaving: take the text from the textarea and push it into
the text-property of your original element
6.) swap back
Best wishes
Harald
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" 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/mochikit
-~----------~----~----~----~------~----~------~--~---