Beginner questions...passing XSL-to javascript and back
This is an open discussion with 24 replies, filed under XSLT.
Search
Forgot to mention:
<xsl:call-template name="keypeople-javascript" />
Where you want it to be output in the page.
I dont't wan't to troll-hijack this thread here, but instead of encouraging people to write bad code, shouldn't we be so clever to teach them how to do right and not how to do the wrong way right?
@gregor
Instead writing inline javascript, why don't you attach the required data to span.link
using the data attribute?
in your template you could do something like:
<span class="link" data-my-data="{your xpath expression}"/>
and in you javascript may do something like:
$(function () { $('parentElement').on('click', 'span.link', function (event) { event.preventDefault(); var data = $(this).data('myData'); // do stuff … }); });
@iwyg that would be my preferred solution (think i mentioned it) it keeps the code cleaner and no inline XSLT; though not sure on the content he's trying to put into the dom.
thanks to the great help of a person which was described to me as "a very wise geek", we got the problem solved and have it running. i documented here:
still some problems. firstly, it can be that the code is not very beautiful, and i will happily welcome all hints on how to produce good code. (for the moment we are haopy that it is working)
one strange thing is still there: when we enter text in the data source, e.g. copy from text editor, it is very likely that some quotation mark, whitespace or so doesn't fit the systems expectations and therefore the whole code won't work anymore. no idea how this comes, but probably thereS a way to escape/purge/tidy the results before passing them?
thanks to the community for the support gregor
Create an account or sign in to comment.
thanks a lot! i will try to get it running!