Reputation: 59
In the parent window I have:
<input type=text size=100 id="picker1" data-listoption="1" data-type="size">
then within the iframe I have
<script>
$(document).ready(function(){
var parent_input = $("#picker1", window.parent.document);
var searchdata = $(parent_input).data();
var listtype = $(parent_input).data('listoption');
console.log(searchdata);
console.log(listtype);
});
and both outputs in the console are empty. What is missing here?
Upvotes: 1
Views: 1767
Reputation: 94429
Jquery does not provide the ability to scope a selector using a window's parent. But you can access jQuery on the parent from the child using parent
.
Try:
var parent_input = parent.$("#picker1");
var searchdata = $(parent_input).data();
var listtype = $(parent_input).data('listoption');
console.log(searchdata);
console.log(listtype);
Working Example http://jsfiddle.net/AEj4Z/
Upvotes: 3