Ok, so basically I'm trying to have a single line of code at the bottom of a post:
<p id="audioembed">Click here to <a href="http://www.site.com/mp3file.mp3"> download MP3</a></p>
And then at the bottom of the page, I have the script to check and see if the user is viewing it on an iPhone, iPad, or iPod, and then pull the mp3 URL, clear the element, and then add a basic HTML5 audio player in its place:
<script>
jQuery(document).ready(function($) {
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
{
var audioElement = $('#audioembed'), href = audioElement.children('a').attr('href');
$.template("audioTemplate", "<audio src='${src}' controls>")
audioElement.empty();
$.tmpl("audioTemplate", {src: href}).appendTo(audioElement);
};
});
</script>
But for some reason, it's not working at all. I know the iDevice check is working (if I replace the template lines with something basic like a CSS color change, it works just fine) so I have to be messing something up with the template. Any light you could shine on this problem would be greatly appreciated.