DWRUtils DWREngine APIの使い方
7053 ワード
$("precloneNode1suf") ;
DWRUtil.selectRange("selectRangeBasic", 5, 15) selectRangeBasic 15 .
DWRUtil._getSelection("selectRangeBasic") selectRangeBasic .
var arrayFive = [ 'One', 'Two', 'Three', 'Four', 'Five' ];
DWRUtil.addOptions('addOptionsBasic', arrayFive); ;
DWRUtil.getValue('addOptionsBasic') addOptionsBasic ;
DWRUtil.getValue("precloneNode1Inner1suf", { textContent:true }); , precloneNode1Inner1suf "UL" , , HTML .
DWRUtil.getText('addOptionsBasic') addOptionsBasic ;
var arrayObject = [
{ name:'One', value:'1' },
{ name:'Two', value:'2' },
{ name:'Three', value:'3' },
{ name:'Four', value:'4' },
{ name:'Five', value:'5' }
];
DWRUtil.addOptions('addOptionsObject1', arrayObject, "name"); ; , ;
DWRUtil.addOptions('addOptionsObject1', arrayObject, "name","value"); , : 3= ;4= ;
var map = { one:1, two:2, three:3, four:4, five:5 };
DWRUtil.addOptions('addOptionsMap1', map); , one ;1 ;
DWRUtil.addOptions('addOptionsMap1', map,true); , 1 ;one ;
-------------------------------------------------------------------------------------
<ul id="removeItems">
<li>One</li><li>Two</li><li>Three</li><li>Four</li><li>Five</li>
</ul>
, ; select ;
-------------------------------------------------------------------------------------
DWRUtil.cloneNode('cloneNode1', { idPrefix:'pre', idSuffix:'suf' }); , id, id pre, suf.( : , )
DWRUtil.addRows(id, array, cellfuncs, [options]);
:
for each member in array
for each function in cellfuncs
create cell from cellfunc(array[i])
, , ;( )
:
DWRUtil.addRows('addRowsBasic', arrayFive, [
function(data) { return data; },
function(data) { return data.toUpperCase(); },
function(data) {
var input = document.createElement("input");
input.setAttribute("type", "button");
input.setAttribute("value", "DOM Test");
input.setAttribute("onclick", "alert('" + data + "');");
return input;
},
function(data) { return "<input type='button' value='innerHTML Test' onclick='alert(\"" + data + "\");'>"; }
]);
:
, ;
function defaultRowCreator(options) {
return document.createElement("tr");
};
function defaultCellCreator(options) {
return document.createElement("td");
};
:
DWRUtil.addRows( "demo2",[ 'Africa', 'America', 'Asia', 'Australasia', 'Europe' ] , cellFuncs, {
rowCreator:function(options) {
var row = document.createElement("tr");
var index = options.rowIndex * 50;
row.style.color = "rgb(" + index + ",0,0)";
return row;
},
cellCreator:function(options) {
var td = document.createElement("td");
var index = 255 - (options.rowIndex * 50);
td.style.backgroundColor = "rgb(" + index + ",255,255)";
td.style.fontWeight = "bold";
return td;
}
});
options :( , )
rowData: the element value from the array (the same for all cells in a row)
rowIndex: the key (if map) or index (if array) from the collection
rowNum: The row number counting from 0 in this section (so if you are using tbody, it counts rows in the tbody and not the whole table)
data: The 'computed' data value for the cell (cellCreators only)
cellNum: The cell number that we are altering counting from 0 (cellCreators only)
DWRUtil.setValues(); ;
var settings = {
setValuesDiv:"setValuesDiv",
setValuesSpan:"setValuesSpan",
setValuesSelect:"two",
setValuesText:"setValuesText",
setValuesPassword:"AB",
setValuesTextarea:"setValuesTextarea",
setValuesButton1:"B1-Two",
setValuesButton2:"B2-Two",
setValuesRadio1:true,
setValuesRadio2:false,
setValuesRadio3:"one",
setValuesRadio4:"two",
setValuesCheckbox1:true,
setValuesCheckbox2:false
};
DWRUtil.setValues(settings);
DWRUtil.getValues(empty); ;
var empty = {
setValuesDiv:null,
setValuesSpan:null,
setValuesSelect:null,
setValuesText:null,
setValuesPassword:null,
setValuesTextarea:null,
setValuesButton1:null,
setValuesButton2:null,
setValuesRadio1:null,
setValuesRadio2:null,
setValuesRadio3:null,
setValuesRadio4:null,
setValuesCheckbox1:null,
setValuesCheckbox2:null
};
DWRUtil.getValues(empty);
DWRUtil.useLoadingMessage("Ping");// gmail , "ping"; , ;http://getahead.ltd.uk/dwr/browser/util/useloadingmessage
DWRUtil.toDescriptiveString("id", ); , 0,1,2. .
DWRUtil.onReturn(event, submitFunction); form , .
:
<input type="text"
onkeypress="DWRUtil.onReturn(event, submitFunction)"/>
<input type="button" onclick="submitFunction()"/>
DWREngine.beginBatch(); ;
DWREngine.endBatch(); ;
DWREngine.defaultMessageHandler(abc); ;
DWREngine.setTextHtmlHandler; html ;< javascript , >
DWREngine._httpSessionId; id;
DWREngine._scriptSessionId; id;
DWREngine.setErrorHandler(abc); ;
DWREngine.setWarningHandler(abc); ;
DWREngine.setTimeout(0); , 0;
DWREngine.setPreHook(abc); dwr ;
DWREngine.setPostHook(abc); dwr ;
// ;
DWREngine.XMLHttpRequest = 1;
DWREngine.IFrame = 2;
DWREngine.ScriptTag = 3;
DWREngine.setMethod(<1 or 2 or 3>); ;
DWREngine.setVerb = function(<'GET' or 'POST'>); ;
DWREngine.setOrdered(<true or false>); xhr .< , .>
DWREngine.setAsync (<true or false>); xhr ? true;( , , . , ).
------------------------------------------------------------------
// , ;
DWREngine.setPolling(); , DWREngine.setReverseAjax() ;
DWREngine.setReverseAjax = function(reverseAjax) {
DWREngine._reverseAjax = reverseAjax;
if (DWREngine._reverseAjax) {
DWREngine._triggerNextPoll(0);
}
};
DWREngine.setPollUsingComet = function(pollComet) {
DWREngine._pollComet = pollComet;
};
DWREngine.setPollMethod(<1 or 2 or 3>); **** ;