Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

JQuery in AA fails to update text field

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
7 months 3 weeks ago #338023 by galanopd
JQuery in AA fails to update text field was created by galanopd
I've been utilizing the following code in the onBeforeUserProfileEditDisplay function in an AA without any issues. However, recently, I've noticed that the text field (cb_branches_no) no longer updates the count.
Code:
$('input[name=_cb_branches__count]').on('change', function() {   $('#cb_branches_no').val($(this).val()); var oldBranches = $('input[name=_cb_branches__count]').val(); setInterval(function(){ //listening for changes   var newBranches = $('input[name=_cb_branches__count]').val();   if(newBranches !== oldBranches){ $('#cb_branches_no').val(newBranches);     oldBranches = newBranches;   } }, 100); }).trigger( 'change' );

Is there any recent modification that might have caused this issue?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
7 months 3 weeks ago #338024 by krileon
Replied by krileon on topic JQuery in AA fails to update text field
Nothing has changed recently in regards to loading JavaScript, jQuery, etc..

I however cannot help you debug custom coding, sorry. You'll need to open your browsers developer tools (usually just press F12) and review the Console tab and see if there are any errors. You might want to also check that your jQuery selectors are correct.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
7 months 3 weeks ago #338025 by galanopd
Replied by galanopd on topic JQuery in AA fails to update text field
I understand.
The reason I am asking is because I have 4 different AA with the almost the same code (only field names are different) that count the records in the field groups and all of them used to work fine until recently.
I haven't changed them at all and suddenly I realize that none of them works...
Anyway, I will check again carefully.

 

Please Log in or Create an account to join the conversation.

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
7 months 3 weeks ago #338032 by galanopd
Replied by galanopd on topic JQuery in AA fails to update text field
Finally, the code is functioning.
What's happening is that the text file is located in the hidden tab, resulting in it not updating.
When I switched tabs, it worked properly.
The issues are as follows:

1. It could be added in a tab (not hidden) to be displayed in profile view but then it would appear in profile edit and I don't want the user to change the value of the file. If I make it read-only so the user can't change it, then it doesn't update.
2. It could be hidden from profile view/profile edit and called through a CustomHTML file in profile view, but still doesn't display since there are restrictions in the profile view.
3. As mentioned earlier, it doesn't update when it's in the hidden tab.

Do you have any suggestions on how to address this issue?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
7 months 3 weeks ago #338033 by krileon
Replied by krileon on topic JQuery in AA fails to update text field
It doesn't really matter if something is hidden or not. You should be able to set its value perfectly fine from JavaScript assuming it exists on the page. I'm not quite sure why you're using a timer though as you're bound to a change event already. What is this suppose to be doing exactly and does it even need to be in JavaScript? Are you trying to store the count of a CB Field Group field?


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
7 months 3 weeks ago #338034 by galanopd
Replied by galanopd on topic JQuery in AA fails to update text field

It doesn't really matter if something is hidden or not. You should be able to set its value perfectly fine from JavaScript assuming it exists on the page.

In my case, when the text field (cb_branches_no) is located within the "hidden" tab, I can retrieve its value (if manually set) in a CustomHTML field for profile view using the following syntax -> [cb:userfield field="cb_branches_no" /].
The issue arises when the user attempts to update the FieldGroup (cb_branches) during profile editing. The AA triggers onBeforeUserProfileEditDisplay and should update the text field (cb_branches_no), but it fails to do so because the field is within the "hidden" tab.
One potential solution is to relocate the text field (cb_branches_no) to another tab, which allows for successful updates. However, this presents a new issue wherein the field becomes visible to the user during profile editing, enabling modifications we don't want.
Setting the text field (cb_branches_no) as "read only" prevents the AA from updating it.

I'm not quite sure why you're using a timer though as you're bound to a change event already.

You're right, but I want the field to be updated instantly when the user adds or removes rows in the FieldGroup (cb_branches) during profile editing.I might omit that though.

What is this suppose to be doing exactly and does it even need to be in JavaScript? Are you trying to store the count of a CB Field Group field?

More or less about what it does is explained above. Regarding JavaScript, is there another way for achieving what I need?


Thank you

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum