Created
March 8, 2015 14:34
-
-
Save alessandro-aglietti/116395f873402488217b to your computer and use it in GitHub Desktop.
Snippet for http://stackoverflow.com/questions/28926980/polymer-accessing-dom-input-element-inside-a-custom-element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../bower_components/polymer/polymer.html"> | |
<script src="../js/snap.svg-min.js"></script> | |
<script src="../js/jquery-1.11.2.min.js"></script> | |
<polymer-element name="proto-element"> | |
<template> | |
<div class="div2"> | |
Source:<input type="text" id="textsrc" value="SOURCE"><br> | |
Destination: <input type="text" id="textdest"><br> Flight:<input | |
type="text" id="textplane"><br> | |
</div> | |
</template> | |
<script> | |
Polymer('proto-element',{ | |
ready: function() { | |
var s = Snap(900,700); | |
var rec1 = s.rect(50,200,150,80); | |
var rec2 = s.rect(350,200,150,80); | |
rec1.attr({ | |
fill: 'lightblue', | |
stroke: 'lightblue', | |
strokeOpacity: .3, | |
strokeWidth: 10, | |
id : 'id111' | |
}); | |
rec2.attr({ | |
fill: 'lightblue', | |
stroke: 'lightblue', | |
strokeOpacity: .3, | |
strokeWidth: 10, | |
id : 'id112' | |
}); | |
var hackthis = this; | |
document.querySelector('#id111').addEventListener('click', function(e) { | |
var txtboxval = hackthis.$.textsrc; | |
alert(txtboxval.value); | |
}); | |
} | |
}); | |
</script> | |
</polymer-element> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment