2012년 11월 13일 화요일

How do I get the root site URL using ECMA script? [closed]


I am attempting to open a popup dialog box, that popup should then open a video library page.
The code works fine on the root site level (e.g. http://hostName:8084/pages/abc.aspx), but when I use the same code for child web (e.g. http://hostName:8084/SomeSite/Pages/abc.aspx) then my popup doesn't open.
I am using this code to open my dialog box:
function OpenDialog(listname, id, width, height) {

    this.ctx = new SP.ClientContext();
    this.sitecoll = this.ctx.get_site();
    this.web = this.sitecoll.get_rootWeb();
    this.ctx.load(this.web);
    this.itemid = id;
    this.listname = listname;
    this.dialogwidth = width;
    this.dialogheight = height;
    this.list = web.get_lists().getByTitle(listname);
    var query = new SP.CamlQuery();
    query.set_viewXml("<View/>");
    this.listItems = this.list.getItems(query);

    this.ctx.load(this.list);
    this.ctx.load(this.listItems);

    ctx.executeQueryAsync(
            Function.createDelegate(this, this.onSuccess),
            Function.createDelegate(this, this.onFail)
        );
}
In a child web this code doesn't use the root site address (e.g. http://hostName:8084).
Is there a way to get the root site address to open the list in the site collection?

Sorry, My system cache was full and I guess it was taking some files from there so this code was not working.. I cleared my cache and created a new site collection. After that I deployed my solution again and it worked. Thanks for everyone's help..

댓글 없음: