Fancybox-passing parameters
Good day, hello everyone.
That's what day I'm messing with fancybox and I can't figure out how to pass the values from the modal window to the page where the form was called from. The essence of the problem is that there is a page on which the city is selected. When you click on select city, a modal window opens, where you need to select a city from the list by checking the box (the option can be multiple), and then there is a button select. When you click on the button select-the modal window should disappear and on the page, instead of the label , select the city - is replaced by the city selected from the list.
On the page /index.php the modal window is called, html:
<div class="bl_categoty">
<div class="choice_category">Выбрать город</div>
<div>
Here is the js:
$(".choice_category").fancybox({
'padding':6,
'href':'/modal/categories.php',
// события при закрытии формы применяется.
beforeClose: function(){
console.log("форма закрыта");
$(".bl_categoty .value_heading").empty().text("ГОРОД");
}
});
The modal window is located in /modal/categories.php. This page has a list of cities and a select button.When you click on it it is necessary that the data is transmitted to the page /index.php and substituted in. choice_category. The page's js code /modal/categories.php below:
$(".action_category").click(function(event){
// value_heading должно записаться выбранный город. - не применяется
$(".bl_categoty .value_heading").empty().text("ГОРОД");
parent.jQuery.fancybox.close(); // событие срабатывает
// не применяется
$('.choice_category').fancybox({
beforeClose: function(){
console.log("*******************");
$(".bl_categoty .value_heading").empty().text("ГОРОД");
}
});
});
How do I pass parameters from a modal window to a page /index.php
Thank you in advance for your answer. I will be very grateful for any help.
2 answers
Solved the problem
$(".action_category").click(function(event){
var category = parent.document.getElementById("category_id");
category.value="Medved"
parent.jQuery.fancybox.close();
});
Your answer can be written as follows:
parent.$('#category_id').val('Medved');