Evo napravio sam neki edit-in-place, tj. preuzeo klasu za isti.
Posto radim sa BBCodeom, imao sam dosta problema.
Sad, ostao mi je jos jedan:
Kako da replaceujem [br] sa \n u textarea.
Kod izgleda ovako:
Code:
function edit(obj,reversed){
Element.hide(obj);
reversed = reversed.replace("[br]","\n");
var textarea = '<div id="'+obj.id+'_editor"><textarea id="'+obj.id+'_edit" name="'+obj.id+'" rows="4" cols="60">'+trim(reversed)+'</textarea>';
var button = '<div style="align:center;"><input id="'+obj.id+'_save" type="button" value="Snimi promjene" /> <input id="'+obj.id+'_cancel" type="button" value="Otkazi" /></div></div>';
new Insertion.After(obj, textarea+button);
Event.observe(obj.id+'_save', 'click', function(){saveChanges(obj)}, false);
Event.observe(obj.id+'_cancel', 'click', function(){cleanUp(obj)}, false);
}
function edit(obj,reversed){
Element.hide(obj);
reversed = reversed.replace("[br]","\n");
var textarea = '<div id="'+obj.id+'_editor"><textarea id="'+obj.id+'_edit" name="'+obj.id+'" rows="4" cols="60">'+trim(reversed)+'</textarea>';
var button = '<div style="align:center;"><input id="'+obj.id+'_save" type="button" value="Snimi promjene" /> <input id="'+obj.id+'_cancel" type="button" value="Otkazi" /></div></div>';
new Insertion.After(obj, textarea+button);
Event.observe(obj.id+'_save', 'click', function(){saveChanges(obj)}, false);
Event.observe(obj.id+'_cancel', 'click', function(){cleanUp(obj)}, false);
}
Medjutim, meni ono reversed = reversed.replace("[br]","\n"); nista ne uradi.
Evo primjera sta dobijem:
Code:
test
[b]Bold[/b][br][b]Bold2[/b][br][b]Bold3[/b]
test
[b]Bold[/b][br][b]Bold2[/b][br][b]Bold3[/b]
Sta da radim?
Hvala,
Jezda.
// Edit:
// Ne bitno, sredio sam.
[Ovu poruku je menjao Neohacker dana 22.06.2007. u 13:56 GMT+1]
“I never think of the future - it comes soon enough.” - Albert Anštajn (Albert Einstein)