ごめんなさい。 これはすべて重要であるかどうかはわかりませんが、場合によっては言及します。 :これはポップアップボックスを一緒に置く機能である、私は単純なポップアップを閉じる方法を理解できません
function begin(some info) is called->Makes an Ajax request to backend PHP->
PHP calls the callback function->Callback function calls another JS function that creates a popup->
In the popup creating function, The Save button is assigned a function that makes an ajax request and sends PHP some user input.->
PHP makes a callback to another function that does nothing.
をここに:ユーザーがリンクをクリックすると、これは何が起こるかです。私はポップアップでSave
ボタンを押したときに
function collection(name, description, data){
var json = data;
var cont = openSitePopup("400","300");
//We create div objects.
var namecell = ce("div","sitePopupCell");
//Stuff
// We create a button and assign the createProducts Method to it.
var sbtbutton = createBtn("submitObject","SAVE","createProducts()");
//We append all the div objects to the popup.
cont.appendChild(namecell);
//..
}
function openSitePopup(width,height) {
//try to center the popup if values are not passed
var xPos = (getWinWidth()/2) - (width/2) + sl;
var yPos = (getWinHeight()/2) - (height/2) + st;
sitepopupwin = ge("sitePopupWin");
clearElement(sitepopupwin);
var winhandle = ce("div","","sitePopupHandle");
sitepopupwin.style.display = "block";
//Other style assignments.
//closebutton
var close = ce("img","sitePopupCloseBtn");
close.setAttribute("src",theme_path + "/images/icons/close.png");
//start adding goodies
var mydiv = ce("div","sitePopupContainer");
winhandle.appendChild(close);
winhandle.appendChild(createCleaner());
sitepopupwin.appendChild(winhandle);
sitepopupwin.appendChild(mydiv);
//return reference to the container for adding stuff
return mydiv;
}
function createProducts()
{
//Some exciting Ajax stuff with a callback to writeNewFolder()
}
function writeNewFolder(data){
//Nothing of interest here...yet.
}
は今、リクエストが正常に行われますが、ポップアップが閉じません。私はWindow.Close()
機能を知っていますが、機能しませんでした。 cont.Close()
は明らかな選択肢のようですが、その場合、私はこのエラーを受け取ります:Uncaught TypeError: Object #<HTMLDivElement> has no method 'Close'
したがって、Contはdiv要素に過ぎません。 openSitePopup()
メソッドはdivだけを返します。
ご協力いただきありがとうございます。
編集:
function ce(elementType,elementClass,elementId,txt) {
var e = document.createElement(elementType);
//add optional parameters
if (elementId) e.setAttribute("id",elementId);
if (elementClass) setClass(e,elementClass);
//append extra text. If passed an object, append with without the textnode wrapper
if (isData(txt)) {
if (typeof(txt)=="object") e.appendChild(txt);
else e.appendChild(ctnode(txt));
}
return e;
}
うまくいけば、元の作成者が、私はここで自分のコードの一部を掲示気にしません。さて、それは無料でオープンソースなので、うまくいくはずです...私は思っています。
編集2:ge
機能。これは簡単です。
function ge(element) {
return document.getElementById(element);
}
私の謝罪!私は 'ce'が標準のJavaScript関数だと思った。基本的に要素を作成します。私はそれを追加します。 – zermy
更新を参照してください..... – mplungjan
あなたのソリューションはうまくいきました、ありがとうございます。あなたは正しい、それはウィンドウの要素ではなく、ただのdivです。なんて面白い。 – zermy