Chris@0: {% autoescape 'js' %} Chris@0: (function (xpath, check) { Chris@0: function getPolterNode(xpath) { Chris@0: var polterAgent = window.__poltergeist; Chris@0: var ids = polterAgent.find("xpath", xpath, document); Chris@0: return polterAgent.get(ids[0]); Chris@0: } Chris@0: Chris@0: var pNode = getPolterNode(xpath); Chris@0: Chris@0: if (check && pNode.element.checked) { Chris@0: //requested to check the element and is already check, do nothing. Chris@0: return true; Chris@0: } Chris@0: Chris@0: if (!check && pNode.element.checked == false) { Chris@0: //move along nothing to be done Chris@0: return true; Chris@0: } Chris@0: Chris@0: if (check && pNode.element.checked == false) { Chris@0: //we have to check the element, we will do so by triggering a click event so all change listeners are aware. Chris@0: pNode.trigger("click"); Chris@0: pNode.element.checked = true; Chris@0: } Chris@0: Chris@0: if (!check && pNode.element.checked) { Chris@0: //move along nothing to be done Chris@0: pNode.trigger("click"); Chris@0: pNode.element.checked = false; Chris@0: return true; Chris@0: } Chris@0: return false; Chris@0: }('{{xpath}}', {{check}})); Chris@0: {% endautoescape %}