dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: onclick event of anchor tag

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    3

    onclick event of anchor tag

    Hi,

    I have an Array called folderArray and I am iterating through using $.each. each element in the folderArray is a URL string. so below script builds a folder hierarchy. However, what I want to do is I want to execute showModal(this) when a user clicks on the anchor. but it is not working. showModal(this) i think it is getting confused with "this" alternatively I tried href= javascript:showModal(this) that also does not work ..please anyone help




    //iterate through array
    $.each(folderArray, function () {


    var parent = elements[this.substring(0, this.lastIndexOf("/"))]

    //if there exists a parent then create a new list.
    var list = parent ? parent.next() : rootDiv;

    if (!list.length) {

    list = $("<div style='margin-left:50px;'></div>").insertAfter(parent);


    }

    var item = $("<div style='margin-left:50px;'></div>").appendTo(list);

    var anchor = $("<a target='_blank'></a>").attr("onclick", showModal(this)).text(this.substring(this.lastIndexOf("/") + 1)).appendTo(item);


    var folderIcon = $("<img border='0' src='_layouts/Images/folder.gif'/>").prependTo(anchor);


    elements[this] = item;


    });


    function DialogCallback(dialogResult, returnValue){ }

    //Open the Form Dialog
    function showModal(windowUrl){
    var options = { url:windowUrl,
    width: 700,
    height: 700,
    dialogReturnValueCallback: DialogCallback
    };
    SP.UI.ModalDialog.showModalDialog(options);

    }

  2. #2
    Join Date
    Jul 2013
    Posts
    3
    Anyone please help...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles