Javascript looping in console
up vote
-1
down vote
favorite
I got code:
$(document).on("click", "a.order_products-collection-rescue-add", function ()
$(".chosen-select").chosen();
var $product_search = $('select.order_product');
$product_search.change(function ()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function (html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr(
'min': quantity_min,
'max': quantity_max
);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
);
And my question is it normal, after run on change function:
$product_search.change(function () {
becomes info about looping all the time this function in console ? Of course everything works fine, but is it normal that should looping in console without end ? Sorry, but i don`t know how to precision this what is happening in console, for example in next change() is getting value of
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
and this looping without end, I tried to add return false to every function, but still looping, did i miss understood something or is it normal ?
(sorry for my english).
<script type="text/javascript">
$('.products-select').collection(position_field_selector: '.my-position');
</script>
<script>
$(document).on("click", "a.order_products-collection-add", function()
$(".chosen-select").chosen('reload');
);
$(document).on("click", "a.order_products-collection-rescue-add", function()
$(".chosen-select").chosen();
);
$('div#order_products').on('change', 'select.order_product', function()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function(html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr('min': quantity_min, 'max': quantity_max, 'value': 1);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$('div#order_products').on('change', 'input.single-quantity-field', function(event)
$value = $(this).val();
console.log($value);
);
</script>
javascript jquery
|
show 10 more comments
up vote
-1
down vote
favorite
I got code:
$(document).on("click", "a.order_products-collection-rescue-add", function ()
$(".chosen-select").chosen();
var $product_search = $('select.order_product');
$product_search.change(function ()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function (html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr(
'min': quantity_min,
'max': quantity_max
);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
);
And my question is it normal, after run on change function:
$product_search.change(function () {
becomes info about looping all the time this function in console ? Of course everything works fine, but is it normal that should looping in console without end ? Sorry, but i don`t know how to precision this what is happening in console, for example in next change() is getting value of
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
and this looping without end, I tried to add return false to every function, but still looping, did i miss understood something or is it normal ?
(sorry for my english).
<script type="text/javascript">
$('.products-select').collection(position_field_selector: '.my-position');
</script>
<script>
$(document).on("click", "a.order_products-collection-add", function()
$(".chosen-select").chosen('reload');
);
$(document).on("click", "a.order_products-collection-rescue-add", function()
$(".chosen-select").chosen();
);
$('div#order_products').on('change', 'select.order_product', function()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function(html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr('min': quantity_min, 'max': quantity_max, 'value': 1);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$('div#order_products').on('change', 'input.single-quantity-field', function(event)
$value = $(this).val();
console.log($value);
);
</script>
javascript jquery
1
Nothing shown creates a loop anywhere. Please provide a Minimal, Complete, and Verifiable example that reproduces such problem
– charlietfl
Nov 10 at 19:57
in console this console.log(value) repeating after first change function on select selector.
– flow
Nov 10 at 21:06
OK . It is because you create change listener inside a click event handler. Every time that button is clicked you add another change event listener
– charlietfl
Nov 10 at 21:10
event.stopPropagation() in every change function made work. its start looping but after my data is loaded it stops, so its ok now.
– flow
Nov 10 at 21:15
Not sure why ... overall creating event listeners inside other event handlers is a really bad practice
– charlietfl
Nov 10 at 21:16
|
show 10 more comments
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I got code:
$(document).on("click", "a.order_products-collection-rescue-add", function ()
$(".chosen-select").chosen();
var $product_search = $('select.order_product');
$product_search.change(function ()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function (html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr(
'min': quantity_min,
'max': quantity_max
);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
);
And my question is it normal, after run on change function:
$product_search.change(function () {
becomes info about looping all the time this function in console ? Of course everything works fine, but is it normal that should looping in console without end ? Sorry, but i don`t know how to precision this what is happening in console, for example in next change() is getting value of
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
and this looping without end, I tried to add return false to every function, but still looping, did i miss understood something or is it normal ?
(sorry for my english).
<script type="text/javascript">
$('.products-select').collection(position_field_selector: '.my-position');
</script>
<script>
$(document).on("click", "a.order_products-collection-add", function()
$(".chosen-select").chosen('reload');
);
$(document).on("click", "a.order_products-collection-rescue-add", function()
$(".chosen-select").chosen();
);
$('div#order_products').on('change', 'select.order_product', function()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function(html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr('min': quantity_min, 'max': quantity_max, 'value': 1);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$('div#order_products').on('change', 'input.single-quantity-field', function(event)
$value = $(this).val();
console.log($value);
);
</script>
javascript jquery
I got code:
$(document).on("click", "a.order_products-collection-rescue-add", function ()
$(".chosen-select").chosen();
var $product_search = $('select.order_product');
$product_search.change(function ()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function (html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr(
'min': quantity_min,
'max': quantity_max
);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
);
And my question is it normal, after run on change function:
$product_search.change(function () {
becomes info about looping all the time this function in console ? Of course everything works fine, but is it normal that should looping in console without end ? Sorry, but i don`t know how to precision this what is happening in console, for example in next change() is getting value of
$single_quantity_field = $('input.single-quantity-field');
$single_quantity_field.change(function ()
$value = $(this).val();
console.log($value);
);
and this looping without end, I tried to add return false to every function, but still looping, did i miss understood something or is it normal ?
(sorry for my english).
<script type="text/javascript">
$('.products-select').collection(position_field_selector: '.my-position');
</script>
<script>
$(document).on("click", "a.order_products-collection-add", function()
$(".chosen-select").chosen('reload');
);
$(document).on("click", "a.order_products-collection-rescue-add", function()
$(".chosen-select").chosen();
);
$('div#order_products').on('change', 'select.order_product', function()
// ... retrieve the corresponding form.
var $form = $(this).closest('form');
// Simulate form data, but only include the selected sport value.
var data = ;
data[$(this).attr('name')] = $(this).val();
// Submit data via AJAX to the form's action path.
var single_price = $(this).closest('div.product-single-row').find('input.single-price-field').attr('id');
var single_quantity = $(this).closest('div.product-single-row').find('input.single-quantity-field').attr('id');
$.ajax(
url: $form.attr('action'),
type: $form.attr('method'),
data: data,
success: function(html)
// Replace current position field ...
var price = $(html).find('input.single-price-field').val();
var quantity_min = $(html).find('input.single-quantity-field').attr('min');
var quantity_max = $(html).find('input.single-quantity-field').attr('max');
$('input#' + single_quantity + '').attr('min': quantity_min, 'max': quantity_max, 'value': 1);
$('input#' + single_price + '').val(price);
// Position field now displays the appropriate positions.
);
);
$('div#order_products').on('change', 'input.single-quantity-field', function(event)
$value = $(this).val();
console.log($value);
);
</script>
javascript jquery
javascript jquery
edited Nov 10 at 22:33
asked Nov 10 at 19:52
flow
517
517
1
Nothing shown creates a loop anywhere. Please provide a Minimal, Complete, and Verifiable example that reproduces such problem
– charlietfl
Nov 10 at 19:57
in console this console.log(value) repeating after first change function on select selector.
– flow
Nov 10 at 21:06
OK . It is because you create change listener inside a click event handler. Every time that button is clicked you add another change event listener
– charlietfl
Nov 10 at 21:10
event.stopPropagation() in every change function made work. its start looping but after my data is loaded it stops, so its ok now.
– flow
Nov 10 at 21:15
Not sure why ... overall creating event listeners inside other event handlers is a really bad practice
– charlietfl
Nov 10 at 21:16
|
show 10 more comments
1
Nothing shown creates a loop anywhere. Please provide a Minimal, Complete, and Verifiable example that reproduces such problem
– charlietfl
Nov 10 at 19:57
in console this console.log(value) repeating after first change function on select selector.
– flow
Nov 10 at 21:06
OK . It is because you create change listener inside a click event handler. Every time that button is clicked you add another change event listener
– charlietfl
Nov 10 at 21:10
event.stopPropagation() in every change function made work. its start looping but after my data is loaded it stops, so its ok now.
– flow
Nov 10 at 21:15
Not sure why ... overall creating event listeners inside other event handlers is a really bad practice
– charlietfl
Nov 10 at 21:16
1
1
Nothing shown creates a loop anywhere. Please provide a Minimal, Complete, and Verifiable example that reproduces such problem
– charlietfl
Nov 10 at 19:57
Nothing shown creates a loop anywhere. Please provide a Minimal, Complete, and Verifiable example that reproduces such problem
– charlietfl
Nov 10 at 19:57
in console this console.log(value) repeating after first change function on select selector.
– flow
Nov 10 at 21:06
in console this console.log(value) repeating after first change function on select selector.
– flow
Nov 10 at 21:06
OK . It is because you create change listener inside a click event handler. Every time that button is clicked you add another change event listener
– charlietfl
Nov 10 at 21:10
OK . It is because you create change listener inside a click event handler. Every time that button is clicked you add another change event listener
– charlietfl
Nov 10 at 21:10
event.stopPropagation() in every change function made work. its start looping but after my data is loaded it stops, so its ok now.
– flow
Nov 10 at 21:15
event.stopPropagation() in every change function made work. its start looping but after my data is loaded it stops, so its ok now.
– flow
Nov 10 at 21:15
Not sure why ... overall creating event listeners inside other event handlers is a really bad practice
– charlietfl
Nov 10 at 21:16
Not sure why ... overall creating event listeners inside other event handlers is a really bad practice
– charlietfl
Nov 10 at 21:16
|
show 10 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242828%2fjavascript-looping-in-console%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242828%2fjavascript-looping-in-console%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Nothing shown creates a loop anywhere. Please provide a Minimal, Complete, and Verifiable example that reproduces such problem
– charlietfl
Nov 10 at 19:57
in console this console.log(value) repeating after first change function on select selector.
– flow
Nov 10 at 21:06
OK . It is because you create change listener inside a click event handler. Every time that button is clicked you add another change event listener
– charlietfl
Nov 10 at 21:10
event.stopPropagation() in every change function made work. its start looping but after my data is loaded it stops, so its ok now.
– flow
Nov 10 at 21:15
Not sure why ... overall creating event listeners inside other event handlers is a really bad practice
– charlietfl
Nov 10 at 21:16