Andy Jarrett // Code. Develop. Create.

Adding Spry includes in a Model Glue template

As the Spry(and any Ajax framework) files aren't the smallest set of files to add to your page you don't want the user to download them if they don't need to. The way I add the Spry files to a display template in Model Glue is per event via a variable defined in the XML controller. For this example I'm going to include the SpryCollapsiblePanel.js file. 1. The first change we make is to your display(also known as Layout) template. At the very top of the template add the following: Then in the <head> section add the following 2. In the ModelGlue.xml we are going to modify a basic event i.eBefore: After:Using the above event we are going to add a variable to the ViewState And thats it. When you go to index?event=page.index the <views> will include your file that needs Spry while setting a variable to tell your Layout <result> to add the line of script to the <head>N.B. There is a deliberate spelling mistake in my MG events due to a small small bug in BlogCFC

I’m here, learning and working away. If you liked this content and want to keep me going, consider buying me a coffee. Your support keeps this site running and the coffee brewing! ☕️