none
Printing SharePoint fields using JQuery.PrintElement - printElement is not a Function Error

    Question

  • I'm trying to create a print functionality using JQuery plugin printElement.

    I'm getting the field values using another JQuery plugin.

    I'm getting a printElement is not a function error. Here's my code

    <script type="text/javascript" src="/sites/Intranet/Code/JQuery/jquery.min.js"></script>
    <script type="text/javascript" src="/sites/Intranet/Code/JQuery/spjs-utility.js"></script>
    <script type="text/javascript" src="/sites/Intranet/Code/JQuery/jquery.printElement.min"></script>
    
    <script language="JavaScript" type="text/javascript">
    //DMC: 10/2013
    //Use for printing Contract Management Labels
    function PrintLabel()
    {
    	//Get Field Values
    	var myCaseFile = getFieldValue("Title",true); //Case File Name
    	var myExtPart = getFieldValue("STG_x0020_External_x0020_Contracting_x0020_Party_x0028_ies_x0029_",true); //External Contracting Parties
    	var myIntPart = getFieldValue("M_x002d_STG_x0020_Contracting_x0020_Party_x0028_ies_x0029_",true); //Internal Contracting Parties
    	var myRespLeg = getFieldValue("ResponsibleLegal",true); //Responsible Person Legal
    	var myCaseFileID = getFieldValue("Case_x0020_File_x0020_ID",true); //Case File ID
    	
    	sHtml = "<div id='dvPrint'><table>";
    	sHtml += "<tr><td>" + myCaseFile + "</td></tr>";
    	sHtml += "<tr><td>" + myExtPart + ";" +  myIntPart + "</td></tr>";
    	sHtml += "<tr><td>" + myRespLeg + "</td></tr>";
    	sHtml += "<tr><td>" + myCaseFileID + "</td></tr>";
    	sHtml += "</table></div>";
    	//var $dvPrint = $(sHtml);
    	//alert($dvPrint.html());
    	//jQuery("#dvPrint").printElement();
    	$(sHtml).printElement();
    }
    </script>
    <div>
    	<input type="button" value="Print Label" onclick="PrintLabel();" />
    </div>


    Artificial intelligence can never beat natural stupidity.

    • Changed type Mikel x Mikel Tuesday, October 22, 2013 8:17 AM This is a question
    Tuesday, October 22, 2013 8:15 AM

Answers

  • Hi 

    in the line below you are missing .js extension

    <script type="text/javascript" src="/sites/Intranet/Code/JQuery/jquery.printElement.min"></script>

    the src should be 

    "/sites/Intranet/Code/JQuery/jquery.printElement.min.js"

    Hope it helps !


    Thanks Santhosh V

    • Marked as answer by Mikel x Mikel Tuesday, October 22, 2013 8:53 AM
    Tuesday, October 22, 2013 8:45 AM

All replies

  • Hi 

    in the line below you are missing .js extension

    <script type="text/javascript" src="/sites/Intranet/Code/JQuery/jquery.printElement.min"></script>

    the src should be 

    "/sites/Intranet/Code/JQuery/jquery.printElement.min.js"

    Hope it helps !


    Thanks Santhosh V

    • Marked as answer by Mikel x Mikel Tuesday, October 22, 2013 8:53 AM
    Tuesday, October 22, 2013 8:45 AM
  • Thanks Man!

    Pretty stupid of me to missed that been googling for hours.


    Artificial intelligence can never beat natural stupidity.

    Tuesday, October 22, 2013 8:54 AM