Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: How to call UpdateListItems from Link

$
0
0
I have a custom DVWP with a list of items using an aggregate data source. In the XSLT I have a link to delete child items. My requirement is to provide one click delete. I have a solution in place using UpdateListItems that works fine. However, I have to make each instance of the script unique. My question: is there a way to pass values from an <a> tag to the script? Although performance is fine during testing, I would like to make the code cleaner if possible.

Just to be clear I would like to pass the item ID and perhaps the List Name from the link to the script similar to how OpenPopUpPage works in OTB SharePoint 2010 (onclick="javascript:OpenPopUpPage('{$editPOC}', RefreshPage, 850, 500); javascript:return false;")

Here is the <a> tag I am using (some text removed for brevity):
<a id="{concat(@ID,'DeletePocAssociation')}" title="" href="#"><img alt="" src="/_layouts/images/CMSUNLINK.gif"/></a>
Here is the script I have embedded in the XSLT:
<script type="text/javascript">
    $(document).ready(function() {
        $("a[id='<xsl:value-of select="concat(@ID,'DeletePocAssociation')"/>']").click(function() {
            delPocAssoc<xsl:value-of select="concat(@ID,'DeletePocAssociation')"/>();
        });
    });
    function delPocAssoc<xsl:value-of select="concat(@ID,'DeletePocAssociation')"/>() {
        $().SPServices({
            operation: "UpdateListItems",
            async: false,
            batchCmd: "Delete",
            listName: "OP POC",
            ID: <xsl:value-of select="@ID"/>,
            debug: true,
            completefunc: refreshPage<xsl:value-of select="concat(@ID,'DeletePocAssociation')"/>
        });
    };
    function refreshPage<xsl:value-of select="concat(@ID,'DeletePocAssociation')"/>() {
        window.location.replace(&apos;<xsl:value-of select="string($thisPage)"/>&apos;);
    };
</script>       

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>