Have a problem.
How can I set parent element event "OnClick" from child window.
I try
newel.onclick = function() {document.forms.form_save_ent.submit();};
No working. Please help. Thanks
Full code
var parenttbl = window.opener.document.getElementById(\"row_panel\");
var newel = window.opener.document.createElement('td');
var elementid = document.getElementsByTagName(\"td\").length
newel.setAttribute('id',elementid);
newel.onclick = function() {document.forms.form_save_ent.submit();};
parenttbl.appendChild(newel);
Chrome write "Uncaught TypeError: Cannot read property 'submit' of undefined"
Related
from the last version update (from openui5 1.36.12 to openui5 1.38.4) the following code is not working anymore:
var myTable = new sap.ui.table.Table();
myTable ._oVSb.attachScroll(function() {
colorTheTableRows();
})
I'm using the "attachScroll" event in order to color the table rows with a specific logic.
Since last openui5 version update I get this error in console:
Uncaught TypeError: Cannot read property 'attachScroll' of undefined
I've tried to debug the problem and it seems that the object _oVSb has be removed from sap.ui.table.Table.
My final goal is to paint the rows with different colors based on the content ... is there any other way to reach this feature?
Thanks
Even i want this event some how came to this thread. i tried #Dopedev solution it was not working then i changed bit in that as below
$("#<tablid>-vsb").scroll(function() {
console.log("Table is scrolled")
});
instead of getting the tbody get the table-id-vsb and attach the scroll function
You can still get scroll event for your table using .scroll() of jQuery.
onAfterRendering: function(){
//Register handler for scroll event
$("tbody").scroll(function(){
// your stuff
});
}
Demo
I know that one of the earlier posts was already marked as the 'right' answer, but it did not work for me, so I thought I would post my working solution, as it might be helpful to others. The following code will work to effectively 'attach' to the vertical scroll event of a table in 1.38:
onAfterRendering: function() {
if (this.firstTime) { //You only want to override this once
var oTable = this.getView().byId("<YOUR_ID_HERE>");
//Get a reference to whatever your custom handler is
var oHandler = this.handleScroll;
//Store a reference to the default handler method
var oVScroll = oTable.onvscroll;
oTable.origVScrollHandler = oVScroll;
oTable.onvscroll = function(i) {
//Call the 'default' UI5 handler
oTable.origVScrollHandler(i);
//Call your handler function, or whatever else you want to do
oHandler();
};
this.firstTime = false;
}
},
var myTable = new sap.ui.table.Table("myTable");
After rendering:
sap.ui.getCore().byId("myTable-vsb").attachScroll(function() {
colorTheTableRows();
})
I have a page loading inside of an iframe, on that page is a form element with two file input tags whose target is set to an iframe inside of same page as the form. When the form is submitted it sends the files to a JSP page which when after processing the fileupload returns writes out some javascript notifying the user that upload has completed and performs some other processing. On FF and Chrome this setup works just fine but for some reason in IE instead of having the form action load inside of the iframe a new window pops up.
I insert the form, inputs and iframe into the DOM of the page that's loaded into the first iframe via the javascript below:
var containerDiv = document.createElement('div');
containerDiv.setAttribute("id", "containerDiv");
containerDiv.style.position = "absolute";
containerDiv.style.top = "360px";
containerDiv.style.left = "20px";
containerDiv.style.width = "300px"
var iFrame = document.createElement('iframe');
iFrame.setAttribute("id", "target-iframe");
iFrame.name = "target-iframe";
iFrame.style.visibility = "hidden";
iFrame.style.height = "50px";
var zipInput = document.createElement('input');
zipInput.setAttribute("type", "file");
zipInput.setAttribute("id", "zipInput");
zipInput.setAttribute("name", "test");
zipInput.setAttribute("title", "Test");
zipInput.style.marginBottom = "10px";
var pdfInput = document.createElement('input');
pdfInput.setAttribute("type", "file");
pdfInput.setAttribute("id", "pdfInput");
pdfInput.setAttribute("name", "test");
pdfInput.setAttribute("title", "Test");
var form = document.createElement('form');
form.setAttribute("id", "uploadForm");
form.setAttribute("enctype", "multipart/form-data");
form.setAttribute("action", "http://servername:8090/xmlserver/jsp/Upload.jsp?BatchID=" + CSForm.getField("BatchID").getValue());
form.setAttribute("method", "POST");
document.getElementById("DFS__pagediv1").appendChild(containerDiv);
document.getElementById("containerDiv").appendChild(form);
document.getElementById("containerDiv").appendChild(iFrame);
document.getElementById("uploadForm").appendChild(zipInput);
document.getElementById("uploadForm").appendChild(pdfInput);
I've set the form target to the iframe name per the code below but it still pops up a new window for IE.
document.getElementById('uploadForm').target = document.getElementById("target-iframe").name;
alert(document.getElementById('uploadForm').target);
document.getElementById('target-iframe').style.visibility="Visible";
document.getElementById("uploadForm").submit();
I hope that it's something basic that I'm missing and I would really appreciate any help or workarounds that you might have.
Thank you in advance!
I used a variation of the following code to resolve this issue. Apparently naming an iFrame in IE doesn't actually name the iFrame.
var iFrameID = 'ID1';
var myIFrame = document.createElement('iframe');
myIFrame.setAttribute('src', 'about:blank');
myIFrame.setAttribute('id', iFrameID);
myIFrame.setAttribute('NAME', iFrameID);
myIFrame.style.display = 'none';
document.body.appendChild(myIFrame);
if((onReadyFunction) && (typeof(onReadyFunction) == 'function')) captureEvent('load', function(){ var iFrame = document.getElementById(iFrameID); var doc = (iFrame.contentDocument)?(iFrame.contentDocument):((iFrame.contentWindow)?(iFrame.contentWindow.document):(self.frames[iFrameID].document)); if (doc.location.href == 'about:blank') { return; } else { onReadyFunction(doc.body.innerHTML); } }, myIFrame);
[B]if(self.frames[iFrameID].name != iFrameID) { /* *** IMPORTANT: This is a BUG FIX for Internet Explorer *** */ self.frames[iFrameID].name = iFrameID; }[/B]
I am implementing drag and drop from a DataGrid onto a List in a Flex 3 AIR application. I would like to have the drag image be a photo (jpg) referenced by a String field in the data grid item, named 'imagePath'. I'm having trouble getting the image to show up during dragging. I have triple checked that it is not because of an invalid path to the image. I have tried Image's source() and load() methods in every way I can think of. I am calling this method 'dragCurrentToList(event)' on a mouseDown event.
private function dragCurrentToList(event:MouseEvent):void
{
var current:Object = event.currentTarget.selectedItem;
var dragImg:Image = new Image();
dragImg.load(current.imagePath);
dragImg.width = 100;
dragImg.width = 100;
var dsource:DragSource = new DragSource();
dsource.addData(current, 'record');
DragManager.doDrag(event.currentTarget as DataGrid, dsource, event, dragImg);
}
This works perfectly if I set the image source to the following bindable variable but I don't want to hardcode the image name.
[Bindable]
[Embed(source='assets/icons/default.jpg')]
public var dragIcon:Class;
...
dragImg.source = dragIcon
...
In your dragCurrentToList method, why are you loading the image instead of just specifying the source attribute as the URL to the image?
http://livedocs.adobe.com/flex/3/langref/mx/controls/SWFLoader.html#source
private function dragCurrentToList(event:MouseEvent):void
{
var current:Object = event.currentTarget.selectedItem;
var dragImg:Image = new Image();
dragImg.source = current.imagePath;
dragImg.width = 100;
dragImg.width = 100;
var dsource:DragSource = new DragSource();
dsource.addData(current, 'record');
DragManager.doDrag(event.currentTarget as DataGrid, dsource, event, dragImg);
}
Also make sure you are responding to the dragStart event. ( http://livedocs.adobe.com/flex/3/langref/mx/core/UIComponent.html#event:dragStart ). And I believe instead of accessing the DragManager class; you should simply modify the dragSource property of the dragStart event.
I am using below code to delete HTML Table row using javascript but its giving me error.
using below code i am creating a column at run time using javascript which contains delete Anchor tag.
var tbody = document.getElementById("<%= tblcriteria.ClientID %>").getElementsByTagName("TBODY")[0];
var row = document.createElement("TR")
var td4 = document.createElement("TD");
var code = "delete";
td4.setAttribute("align", "center");
td4.innerHTML = code;
row.appendChild(td4);
tbody.appendChild(row);
Below function i am using to delete current row of html table:
function deleteCriteria(i) {
if (window.confirm('Are you sure you want to delete this record?') == true) {
document.getElementById("<%= tblcriteria.ClientID %>").deleteRow(i);
}
}
its giving me below error:
'this.parentNode.parentNode.rowIndex' is null or not an object
Please tell me where i am making mistake...
this does not point to the <a> element, but to the window.
As #Sjoerd has mentioned you should use onClick instead.
This line
var code = "delete";
should read
var code = "<a href=\'#\' onclick=\'javascript:deleteCriteria(this.parentNode.parentNode.rowIndex);\'>delete</a>";
I have a child window and a parent window with a hiddenfield hdnSelectedFields .I am changing the value of hdnSelectedFields.
Code:
String vStrScript = "<script language=javascript>function CloseParent() {window.opener.document.getElementById('hdnSelectedFields').Value = '" + tempstring + "'; alert(window.opener.document.getElementById('hdnSelectedFields').Value);window.close(); } window.opener.document.forms[0].submit(); setTimeout(CloseParent, 5);</script>";
When I close the window the hdnSelectedFields value is set but when I access the hdnSelectedFields on parent window pageload it shows old value of hdnSelectedFields.
if you see the alert in JavaScriptit shows updated hdnSelectedFields value when parent is loaded completed.
Any suggestion how can I access hdnSelectedFields updated value on parent pageload.
Dee
The property of the input box you want is value, not Value.
first of all: you should go for the #-selector, as ids must be unique per definition!
in your popup:
$(document).ready(function() {
setTimeout(function() {
var hiddenField = $('#hdnSelectedFields', window.opener);
// you could do some checking here, eg. hiddenField.length for ensuring existance
hiddenField.val('new value');
alert(hiddenField.val()); // for debug reason
window.opener.document.forms[0].submit();
window.close();
}, 5);
});
in your opener:
$(document).ready(function() {
var hiddenField = $('#hdnSelectedFields');
var hiddenFieldValue = hiddenField.val();
alert(hiddenFieldValue); // for debug reason
});
edit:
your fatal mistake is following:
function CloseParent() {
window.opener.document.getElementById('hdnSelectedFields').Value = '" + hdnCheckedAttribute.Value + "';
window.close();
}
window.opener.document.forms[0].submit();
setTimeout(CloseParent, 15);
so, what will happen when you open the popup?
... biiig drum roll!
submit the form
wait 15ms
set the hiddenField
somewhere in between pt 1 and 3 your $(document).ready() of your opener happens ...
missing pt 3 (due to parallelism), no value is set to the hiddenField.
you might see my workaround in my solution for your popup, which states:
setTimeout(function() {
[...]
window.opener.document.forms[0].submit();
window.close();
}, 5);
window.opener.$('#hiddenvariable').val('somevalue');