getting error when retrieving the datas from the row using an id and displaying it in the textfield in next page..and another error is all the rows are getting deleted when passing id for a specific row..
Here is the coding:
var data = [];
var db = Titanium.Database.open('trip');
db.execute('CREATE TABLE IF NOT EXISTS newtrip (id INTEGER PRIMARY KEY AUTOINCREMENT, triplabel TEXT,tripname TEXT,destination TEXT,fromdate TEXT,todate TEXT)');
//db.execute('INSERT INTO newtrip(triplabel,tripname,destination,fromdate,todate) VALUES(?,?,?,?,?)',"British museum","mytrip","london","12-10-2014","12-12-2014");
//db.execute('DELETE FROM newtrip');
var resultrows = db.execute('SELECT destination,fromdate,todate FROM newtrip');
while (resultrows.isValidRow()) {
//var res=
var row = Ti.UI.createTableViewRow({
height : Ti.UI.SIZE,
rightImage : '/images/right1.png',
layout : 'absolute'
});
var tripnamelabel = Ti.UI.createLabel({
//text : 'Buckingham Palace',
text : resultrows.fieldByName('destination'),
color : theme_style,
font : {
fontSize : '16dp',
fontWeight : 'bold'
},
top : '10dp',
left : '10dp',
//right:'30dp'
});
var gettablecount = resultrows.rowCount;
for (var i = 0; i < gettablecount; i++) {
var data_edit = [];
var imgedit = Ti.UI.createButton({
backgroundImage : '/images/list_edit.png',
// left:'200dp',
top : '20dp',
width : wb,
height : hb,
// bottom:10,
right : '20dp',
onClick : "edit",
rowid : resultrows.fieldByName('id')
});
if (resultrows.isValidRow()) {
imgedit.addEventListener('click', function(e) {
var db = Titanium.Database.open('trip');
if (e.source.onClick == "edit") {
var x = db.execute('SELECT * FROM newtrip WHERE id=' + rowid);
//alert(x);
var createnewWindowback = require('ui/apppage5');
//the name of the url you wish to move
new createnewWindowback(e.source.rowid).open();
win.close();
}
resultrows.close();
db.close();
});
}
}
for (var i = 0; i < gettablecount; i++) {
var imgdelete = Ti.UI.createButton({
backgroundImage : '/images/delete_ic.png',
// left:'240dp',
top : '20dp',
width : wb,
height : hb,
//bottom:'20dp',
right : '60dp',
onClick : "delete",
rowid : resultrows.fieldByName('id')
});
imgdelete.addEventListener('click', function(e) {
var db = Titanium.Database.open('trip');
if (e.source.onClick == "delete") {
var x = db.execute('DELETE FROM newtrip WHERE id=' + rowid);
alert("you have just clicked the delete button");
}
resultrows.next();
db.close();
});
}
var fromdate = Ti.UI.createLabel({
//text : '10.11.2014',
text : resultrows.fieldByName('fromdate'),
color : 'Black',
font : {
fontSize : '13dp',
fontWeight : 'bold'
},
top : '40dp',
left : '10dp',
right : '10dp',
bottom : '20dp'
});
var dash = Ti.UI.createLabel({
text : '-',
color : 'Black',
font : {
fontSize : '15dp',
fontWeight : 'bold'
},
top : '40dp',
left : '80dp',
right : '10dp',
bottom : '20dp'
});
var todate = Ti.UI.createLabel({
text : resultrows.fieldByName('todate'),
color : 'Black',
font : {
fontSize : '13dp',
fontWeight : 'bold'
},
top : '40dp',
left : '90dp',
right : '10dp',
bottom : '20dp'
});
row.add(tripnamelabel);
row.add(imgedit);
row.add(imgdelete);
row.add(fromdate);
row.add(dash);
row.add(todate);
row.className = 'control';
data.push(row);
resultrows.next();
}
resultrows.close();
db.close();
triplistview.setData(data);
I think you not able to fetch data according to id field because you fetch the data in resultrows variable as :
var resultrows = db.execute('SELECT destination,fromdate,todate FROM newtrip');
So here you do not fetch the id column. But you use it at :
rowid : resultrows.fieldByName('id') // in : var imgedit
Hence rowid for var imgedit would be null/undefined. You should modify your SELECT query as :
var resultrows = db.execute('SELECT id,destination,fromdate,todate FROM newtrip');
Edit : Under click listener of imgedit you have :
var x = db.execute('SELECT * FROM newtrip WHERE id=' + rowid);
But there is no variable rowid defined, hence error is thrown. Make following changes ( rowid changed to e.source.rowid) :
var x = db.execute('SELECT * FROM newtrip WHERE id=' + e.source.rowid);
Hope it helps.
Related
I'm trying to create a popup like this
A user presses a button and a selection of options appear, which I call a popup.
In the meantime the background goes black transparant.
I've spend the last few hours online trying to find a good example of how to achieve this, but without luck.
Oh yeah, I would like to use alloy to define the popup.
Thanks in advance for your help!
hey #falcko this is an example of how to create popup window
hope this help
logout_view.addEventListener("click",function(){
var t = Titanium.UI.create2DMatrix();
t = t.scale(0);
var w = Titanium.UI.createWindow({
height:Ti.UI.FILL,
width:Ti.UI.FILL,
transform:t,
backgroundColor:"transparent",
// opacity:0.5
});
var v = Titanium.UI.createView({
backgroundColor:'white',
// height:"240dp",
//width:"293dp",
height:Ti.UI.FILL,
width:Ti.UI.FILL,
backgroundColor:"black",
opacity:0.7
});
var popup=Ti.UI.createView({
height:"240dp",
width:"293dp",
backgroundColor:"white",
});
var plz=Ti.UI.createLabel({
text:"Please specify the reason for reporting",
top:"21dp",
width:Ti.UI.FILL,
textAlign:"center",
font : {
fontFamily : customfont,
fontSize : "16dp"
},
color:"#454545",
});
var check1=Ti.UI.createView({
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
left:"16dp",
top:"55dp"
});
var checkbox1=Ti.UI.createView({
width:"8dp",
height:"8dp",
borderRadius:"4dp",
borderColor:"#CBCBCB",
borderWidth:"0.5dp",
left:"0dpdp",
selected:1
});
var serious=Ti.UI.createLabel({
left:"20dp",
text:"User wasn't serious",
font : {
fontFamily : customfont2,
fontSize : "15dp"
},
//top:"53dp",
color:"#666666"
});
check1.add(serious);
check1.add(checkbox1);
popup.add(check1);
var check2=Ti.UI.createView({
width:Ti.UI.SIZE,
height:Ti.UI.SIZE,
left:"16dp",
top:"79dp"
});
var checkbox2=Ti.UI.createView({
width:"8dp",
height:"8dp",
borderRadius:"4dp",
borderColor:"#CBCBCB",
borderWidth:"0.5dp",
left:"0dp",
selected:0
});
var rude=Ti.UI.createLabel({
left:"20dp",
text:"User was rude and abusive",
font : {
fontFamily : customfont2,
fontSize : "15dp"
},
//top:"76dp",
color:"#666666"
});
check2.add(rude);
check2.add(checkbox2);
popup.add(check2);
var checkbox3=Ti.UI.createView({
width:"8dp",
height:"8dp",
borderRadius:"4dp",
borderColor:"#CBCBCB",
borderWidth:"0.5dp",
left:"16dp",
top:"102dp",
selected:0
});
var foul=Ti.UI.createLabel({
left:"36dp",
text:"User used foul language",
font : {
fontFamily : customfont2,
fontSize : "15dp"
},
top:"100dp",
color:"#666666"
});
popup.add(foul);
popup.add(checkbox3);
var checkbox4=Ti.UI.createView({
width:"8dp",
height:"8dp",
borderRadius:"4dp",
borderColor:"#CBCBCB",
left:"16dp",
borderWidth:"0.5dp",
top:"126dp",
selected:0
});
var other=Ti.UI.createLabel({
left:"36dp",
text:"Other",
font : {
fontFamily : customfont2,
fontSize : "15dp"
},
top:"123dp",
color:"#666666"
});
popup.add(other);
popup.add(checkbox4);
checkbox1.addEventListener("click",function(){
if(checkbox1.selected==0){
checkbox1.setBackgroundColor(o_color);
checkbox1.selected=1;
checkbox2.setBackgroundColor("white");
checkbox2.selected=0;
checkbox3.setBackgroundColor("white");
checkbox3.selected=0;
checkbox4.setBackgroundColor("white");
checkbox4.selected=0;
}
});
checkbox2.addEventListener("click",function(){
if(checkbox2.selected==0){
checkbox1.setBackgroundColor("white");
checkbox1.selected=0;
checkbox2.setBackgroundColor(o_color);
checkbox2.selected=1;
checkbox3.setBackgroundColor("white");
checkbox3.selected=0;
checkbox4.setBackgroundColor("white");
checkbox4.selected=0;
}
});
checkbox3.addEventListener("click",function(){
if(checkbox3.selected==0){
checkbox1.setBackgroundColor("white");
checkbox1.selected=0;
checkbox3.setBackgroundColor(o_color);
checkbox3.selected=1;
checkbox2.setBackgroundColor("white");
checkbox2.selected=0;
checkbox4.setBackgroundColor("white");
checkbox4.selected=0;
}
});
checkbox4.addEventListener("click",function(){
if(checkbox4.selected==0){
checkbox1.setBackgroundColor("white");
checkbox1.selected=0;
checkbox4.setBackgroundColor(o_color);
checkbox4.selected=1;
checkbox2.setBackgroundColor("white");
checkbox2.selected=0;
checkbox3.setBackgroundColor("white");
checkbox3.selected=0;
}
});
popup.add(plz);
var other_view=Ti.UI.createView({
top:"154dp",
left:"15dp",
right:"15dp",
height:"30dp",
borderWidth:1,
borderColor:"#C9C9C9"
});
var send=Ti.UI.createButton({
title:"Send",
height:"33dp",
top:"197dp",
color:"white",
width:"102dp",
backgroundColor:o_color,
font : {
fontFamily : customfont,
fontSize : "13dp"
},
});
popup.add(send);
popup.add(other_view);
// create first transform to go beyond normal size
var t1 = Titanium.UI.create2DMatrix();
t1 = t1.scale(1.1);
var a = Titanium.UI.createAnimation();
a.transform = t1;
a.duration = 200;
// when this animation completes, scale to normal size
a.addEventListener('complete', function()
{
Titanium.API.info('here in complete');
var t2 = Titanium.UI.create2DMatrix();
t2 = t2.scale(1.0);
w.animate({transform:t2, duration:200});
});
v.addEventListener('click', function()
{
var t3 = Titanium.UI.create2DMatrix();
t3 = t3.scale(0);
w.close();
});
w.add(v);
w.add(popup);
w.open(a);
}
);
I want to be able to put a different button inside every row (createTableViewRow). I have created five buttons (Titanium.UI.createButton), but I don't know how to place all five of my buttons for each created row.
Can somebody give me a hint on how to do it?
function sendAjax() {
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e){
var error = e.error;
alert(error);
};
xhr.open('GET', 'http://xxxxxxxxxxxxxx');
xhr.send();
var tv = Titanium.UI.createTableView({
height: Titanium.UI.SIZE,
width: Titanium.UI.FILL
});
win2.add(tv);
xhr.onload = function() {
var data = [];
var schools = JSON.parse(this.responseText);
for (s in schools) {
data.push(Titanium.UI.createTableViewRow({
title: schools[s].Name
}));
}
tv.data = data;
};
}
You should add the listener event on the tableView, not on each buttons inside the row :
tableView.addEventListener("click", function (event) {
if (event.source.buttonid) {
//it's a button
}
});
Try this,
var win = Ti.UI.createWindow({
backgroundColor : '#fff'
});
var tableData = [];
for(var i = 0; i < 10; i++) {
var row = Ti.UI.createTableViewRow();
var button = Ti.UI.createButton({
title : 'Button ' + i,
width : 100,
height : 40,
buttonid : i //our custom button property
});
row.add(button);
tableData.push(row);
button.addEventListener('click', function(e) {
Ti.API.info('button ' + e.source.buttonid + ' clicked.');
alert('Button ' + e.source.buttonid);
});
}
var tableView = Ti.UI.createTableView({
data : tableData
});
win.add(tableView);
win.open();
This answer find from here
UPDATE :
function sendAjax() {
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e){
var error = e.error;
alert(error);
};
xhr.open('GET', 'http://xxxxxxxxxxxxxx');
xhr.send();
var tv = Titanium.UI.createTableView({
height: Titanium.UI.SIZE,
width: Titanium.UI.FILL
});
win2.add(tv);
xhr.onload = function() {
var data = [];
var schools = JSON.parse(this.responseText);
for (s in schools) {
var row = Ti.UI.createTableViewRow();
var rowItem = Ti.UI.createView({
height : 40,
width : Ti.UI.FILL,
layout : 'horizontal'
});
row.add(rowItem);
var title = Ti.UI.createLabel({
height : 40,
text : schools[s].Name,
width : Ti.UI.SIZE
});
rowItem.add(title);
var button = Ti.UI.createButton({
title : 'click ',
width : 100,
height : 40,
buttonid : s //our custom button property
});
rowItem.add(button);
data.push(row);
button.addEventListener('click', function(e) {
Ti.API.info('button ' + JSON.stringify(e.source.buttonid) + ' clicked.');
});
};
tv.data = data;
};
};
Don't forget to mark this as correct answer If this useful.
I am using multi-select grid functionality in my application and it is working as i expected. But the issue is i need to get all the selected records across the pagination in external javascript function. Below is my code,
function createCommodity(){
$.ajax({
url : 'commoditycategory.do?method=listCommodity' + '&random='
+ Math.random(),
type : "POST",
async : false,
success : function(data) {
$("#list2").jqGrid('GridUnload');
var newdata = jQuery.parseJSON(data);
var wWidth = $(window).width();
var dWidth = wWidth * 0.7;
var wHeight = $(window).height();
var dHeight = wHeight * 0.5, idsOfSelectedRows = [];
jQuery("#list2").jqGrid({
data : newdata,
datatype : "local",
colNames : [ "id", "Commodity Code",
"Commodity Description", "Commodity Category" ],
colModel : [
{
name : 'id',
index : 'id',
hidden : true,
editable : true
},
{
name : 'commodityCode',
index : 'commodityCode',
align : "center",
editable : true,
editrules : {
required : true
}
},
{
name : 'commodityDesc',
index : 'commodityDesc',
align : "center",
editable : true,
editrules : {
required : true
}
},
{
name : 'commodityCategoryId',
index : 'commodityCategoryId',
align : "center",
// hidden : true,
editable : true,
edittype : "select",
editoptions : {
dataUrl : 'commoditycategory.do?method=parentCategory'
+ '&random=' + Math.random()
},
editrules : {
edithidden : true,
required : true
// custom : true
}
} ],
pager : "#pager2",
rowNum : 10,
rowList : [ 10, 20, 50 ],
height : "230",
width : dWidth,
onSelectRow: function (id, isSelected) {
var p = this.p, item = p.data[p._index[id]], i = $.inArray(id, idsOfSelectedRows);
item.cb = isSelected;
if (!isSelected && i >= 0) {
idsOfSelectedRows.splice(i,1); // remove id from the list
} else if (i < 0) {
idsOfSelectedRows.push(id);
}
},
loadComplete: function () {
var p = this.p, data = p.data, item, $this = $(this), index = p._index, rowid, i, selCount;
for (i = 0, selCount = idsOfSelectedRows.length; i < selCount; i++) {
rowid = idsOfSelectedRows[i];
item = data[index[rowid]];
if ('cb' in item && item.cb) {
$this.jqGrid('setSelection', rowid, false);
}
}
},
multiselect : true,
cmTemplate : {
title : false
}
});
$grid = $("#list2"),
$("#cb_" + $grid[0].id).hide();
$("#jqgh_" + $grid[0].id + "_cb").addClass("ui-jqgrid-sortable");
cbColModel = $grid.jqGrid('getColProp', 'cb');
cbColModel.sortable = true;
cbColModel.sorttype = function (value, item) {
return typeof (item.cb) === "boolean" && item.cb ? 1 : 0;
};
}
});
}
Till now its working great. Its holding correct rows which are selected across pagination.
And My external JS function where i need to get the selected rowids include pagination is,
function updateCommodity() {
var grid = jQuery("#list2");
var ids = grid.jqGrid('getGridParam', 'selarrrow'); // This only returns selected records in current page.
if (ids.length > 0) {
var html = "<table id='commodityTable' class='main-table' width='100%' border='0' style='border:none;border-collapse:collapse;float: none;'><thead><td class='header'>Commodity Code</td><td class='header'>Commodity</td><td class='header'>Action</td></thead><tbody>";
for ( var i = 0, il = ids.length; i < il; i++) {
var commodityCode = grid.jqGrid('getCell', ids[i],
'commodityCode');
var commodityDesc = grid.jqGrid('getCell', ids[i],
'commodityDesc');
html = html
+ "<tr class='even' id='row" + i + "'><td><input type='text' name='commodityCode' id='geographicState"+i+"' class='main-text-box' readonly='readonly' value='" + commodityCode + "'></td>";
html = html
+ "<td><input type='text' name='commodityDesc' id='commodityDesc"+i+"' class='main-text-box' readonly='readonly' value='" + commodityDesc + "'></td>";
html = html
+ "<td><a style='cursor: pointer;' onclick='deleteRow(\"commodityTable\",\"row"
+ i + "\");' >Delete</a></td></tr>";
}
html = html + "</tbody></table>";
$("#commodityArea").html(html);
}
}
Update I have fiddled the issue for providing more clarity about the issue.
First of all I want remind that you use the code which I posted in the answer.
I see that the solution of your problem is very easy. The list of options of jqGrid can be easy extended. If you just include new property in the list of options
...
data : newdata,
datatype : "local",
idsOfSelectedRows: [],
...
you will don't need more define the variable idsOfSelectedRows (see the line var dHeight = wHeight * 0.5, idsOfSelectedRows = []; of you code). To access new option you can use
var ids = grid.jqGrid('getGridParam', 'idsOfSelectedRows');
instead of var ids = grid.jqGrid('getGridParam', 'selarrrow');. To make the code of onSelectRow and loadComplete callbacks working with idsOfSelectedRows as jqGrid option you should just modify the first line of the callbacks from
var p = this.p, ...
to
var p = this.p, idsOfSelectedRows = p.idsOfSelectedRows, ...
It's all.
UPDATED: See http://jsfiddle.net/OlegKi/s2JQB/4/ as the fixed demo.
I'm working on a Titanium application where I need to show multiple markers on a map. I get the data for these markers trough a JSON array, which can be found here. I am getting no errors, I even get the 'Succes' alert, but still nothing is showing on the map.
var pin = [];
var mapview = Ti.Map.createView({
height : '90%',
mapType : Ti.Map.STANDARD_TYPE,
animate : true,
regionFit : true,
userLocation : true,
region : {
latitudeDelta : 0.05,
longitudeDelta : 0.05
}
});
var xhr = Ti.Network.createHTTPClient({
onload : function(e) {
var data = JSON.parse(this.responseText);
for (var i = 0; i < data.length; i++) {
pin[i] = Titanium.Map.createAnnotation({
latitude : data.rows[i][7],
longitude : data.rows[i][8],
title : data.rows[i][3],
subtitle : data.rows[i][9],
pincolor : Titanium.Map.ANNOTATION_PURPLE,
animate : true,
myid : i
});
mapview.addAnnotation(pin[i]);
}
Ti.API.debug(this.responseText);
alert('success');
},
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000
});
xhr.open("GET", query);
xhr.send();
win.add(mapview);
win.open();
Any help is very much appreciated!
Finally got it to work. Adjusted the code in the question to this:
var mapview = Ti.Map.createView({
height : '90%',
mapType : Ti.Map.STANDARD_TYPE,
animate : true,
regionFit : true,
userLocation : true,
region : {
latitudeDelta : 1.7,
longitudeDelta : 1.7
}
});
win.add(mapview);
var annotations = [];
var query = '..JSON URL..';
var xhr = Ti.Network.createHTTPClient({
onload : function(e) {
var data = JSON.parse(this.responseText);
Ti.API.info('Datum=' + data.rows[1][0]);
for (var i = 0; i < data.rows.length; i++) {
var marker = Titanium.Map.createAnnotation({
latitude : data.rows[i][7],
longitude : data.rows[i][8],
title : data.rows[i][3],
subtitle : data.rows[i][9],
pincolor: Ti.Map.ANNOTATION_GREEN,
animate : true,
myid : i
});
mapview.addAnnotation(marker);
}
Ti.API.debug(this.responseText);
},
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
timeout : 5000
});
xhr.open("GET", query);
xhr.send();
This will populate the map with multiple annotations.
Added tinyMCE as inline editor. Have a next probllem : first time this is work good - show with custom style (as I setup), works correctly but when I click cancel and then start edit again I have empty editor - without text in edit area. so this is a code:
UPD : cm.Node - wrapper for docuement.createElement and el.setAttribute, cm.getByAttr('attr', 'attr_val', el) - get elemnt by attr from el. req - wrapper for AJAX, cm.merge - like array_merge in PHP
var EditBlock = function(){
var my = this;
var o = cm.merge({
'id' : '',
'act' : '',
'val' : '',
'nobr' : false,
'text' : false,
'onSaved' : function(){},
'onSave' : function(){},
'params' : {'iconsPath' : 'interface/common/images/stdc/nicEditorIcons.gif'}
}, arguments[0]);
var prefix = 'tinyMCE_' + Math.random() + '_';
var node = cm.getEl(o.id);
var txtArea = cm.addClass(cm.Node('textarea', {'id' : prefix + o.id, 'style': ('width:' + node.offsetWidth + 'px')}), prefix + o.id);
var saveBtn = cm.Node('input', {'type':'button', 'value':'Save'});
var cancelBtn = cm.Node('input', {'type':'button', 'value':'Cancel'});
var container = cm.Node('div', txtArea, cm.Node('div', saveBtn, cancelBtn));
var plainText = function(node){
var str = '';
var childs = node.childNodes;
for(var i = 0, ln = childs.length; i < ln; i++){
if(childs[i].nodeType == 3)
str += childs[i].nodeValue;
else if(childs[i].childNodes.length)
str += plainText(childs[i]);
}
return str;
}
var init = function(){
node.onclick = my.edit;
cancelBtn.onclick = my.close;
saveBtn.onclick = function(){
my.save();
my.close();
}
}
my.save = function(){
var tmp = cm.Node('div', tinyMCE.get(prefix + o.id).getContent());
var content = o.text? plainText(tmp) : tmp.innerHTML;
o.onSave(content);
node.innerHTML = content;
req({
'act' : o.act,
'data' : 'data[content]=' + escape(content) + (o.val? '&data[val]=' + o.val : ''), 'handler' : function(){o.onSaved(content)}
});
}
my.close = function(){
tinyMCE.init({
'editor_deselector' : prefix + o.id
});
container.parentNode.removeChild(container);
node.style.display = 'block';
}
my.edit = function(){
txtArea.value = node.innerHTML;
node.style.display = 'none';
node.parentNode.insertBefore(container, node);
var styles = '';
var styleRef = cm.getByAttr('rel', 'stylesheet');
for(var i = 0, ln = styleRef.length; i < ln; i++){
styles += (i > 0? ',' : '') + styleRef[i].href;
}
tinyMCE.init({
'height' : '100%',
'content_css' : styles + ',/sdtc-new/nc/interface/common/css/mce-editor.css',
'mode' : "specific_textareas",
'editor_selector' : prefix + o.id
});
}
init();
}
use this like :
new EditBlock({'onSave' : function(content){
page.content = content;
viewDepartment(page);
}, 'id':'depContent', 'act' : '/departments/setContent/', 'val' : page.id, 'params' : {buttonList : ['fontSize','bold','italic','underline','strikeThrough','html']}});
So ... again about problem. When first time start to edit that all works fine when click save - all works too (still exists some bugs but after saving I can click and start edit again) but when click cancel that editor is hide but when I click to edit again I have a empty edit area. I see to console and find that after canceling when I start editing again then I create new edit but old not destroy - only hidden.
I try to usetynyMCE.Editor class methods like hide and show and setContent and was a some result - after canceling I could edit egain but edit area was without styles and buttons.
Please help. If would be quaestion by code - I pleasure to answer.
Thanks.
Don't use hide() and show() here. You should shut down tinymce correctly in order to be able to reinitialize a tinymce editor with the same id as the first one.
To shut down an edtor instance use:
tinymce.execCommand('mceRemoveControl',true,'editor_id');
To reinitialize use
tinymce.execCommand('mceAddControl',true,'editor_id');
Please note!
These have since changed, you may have better luck with (for newer versions, 4+ I think):
try mceRemoveEditor and mceAddEditor instead...as in:
tinymce.execCommand('mceRemoveEditor',true,'editor_id');
tinymce.execCommand('mceAddEditor',true,'editor_id');