NetTalk Central

Author Topic: 2 radio fields on same page with same values  (Read 3672 times)

Stu

  • Hero Member
  • *****
  • Posts: 509
    • View Profile
    • Email
2 radio fields on same page with same values
« on: August 07, 2015, 07:21:39 PM »
Hi Bruce/Folks,

I've got a popup form with two radio fields on it, and each of those fields have the same set of values (see screen 1).

When you load up the page with firebug running, you get:

Code: [Select]
Error: cannot call methods on button prior to initialization; attempted to call method 'widget' (see screen 2).

Googling this led me here, https://forum.jquery.com/topic/uncaught-error-cannot-call-methods-on-button-prior-to-initialization-attempted-to-call-method-widget - the answer on this seems to be saying it's something that jquery can't handle.

Any ideas how I might be able to get around this?

EDIT: Am thinking I could try using different values in the second radio field, although that won't be ideal (I'll have to manually change them back on saving the record).

Stu

[attachment deleted by admin]
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: 2 radio fields on same page with same values
« Reply #1 on: August 09, 2015, 11:22:10 PM »
Hi Stu,

I think I'd need to see an example to comment. The fact that the radios have the same _value_ is not the problem (there are endless radios with yes/no for example.)

The error you are seeing is usually because of something else wrong in the code - specifically some javascript that is out of order. So I suspect it has nothing to do with them being the same (you could change one to prove that theory) and a lot more to do with some script you are doing - or is being done for you - when the popup opens.

cheers
Bruce

Stu

  • Hero Member
  • *****
  • Posts: 509
    • View Profile
    • Email
Re: 2 radio fields on same page with same values
« Reply #2 on: August 10, 2015, 02:17:30 AM »
Hi Bruce,

Apologies, my post wasn't clear .. The link talks about having the same "name" value being the problem.

I'll try and figure out more then if you think it's another script (is a generic file popup form from a browse, this particular nettalk system doesn't have any custom js files).

Stu
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: 2 radio fields on same page with same values
« Reply #3 on: August 10, 2015, 11:15:44 PM »
I think names can be duplicated, as long as the id's are unique - but do they have the same name? That would seem somewhat counter-productive to me in this case....

cheers
Bruce

Stu

  • Hero Member
  • *****
  • Posts: 509
    • View Profile
    • Email
Re: 2 radio fields on same page with same values
« Reply #4 on: August 19, 2015, 01:11:10 AM »
Hey Bruce,

Not sure - they are generic nettalk radio fields (ie, it's not me setting the name).

The field names that are using the two radio sets definitely have different names.

Stu
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: 2 radio fields on same page with same values
« Reply #5 on: August 20, 2015, 06:37:55 AM »
I suspect we're rapidly approaching example time - I'm not sure I 100% understand what is going on.

cheers
Bruce

Stu

  • Hero Member
  • *****
  • Posts: 509
    • View Profile
    • Email
Re: 2 radio fields on same page with same values
« Reply #6 on: August 23, 2015, 05:52:32 PM »
Yeah, it's a bit of a complicated one. I've just done up an example, and narrowed down what was going on.

Am going to change what I'm doing, because I think my own logic is bad - but here's what it was.

If you put a Radio field AND a string (or other field) on the form FROM THE SAME DATA FIELD, that's where you get issues.

IE, I want radio options, but then if the user clicks on "Custom" I want them to be able to enter their own value in that field.

This is where you get the javascript error.

I've attached the example.

** My guess is that at some stage the field name rather than the field equate is being used - but that's just a guess.

HOWEVER:

I don't like my logic to use the same field to put in a custom value. Am going to add another field that holds the custom value (with the original field being the "context").


[attachment deleted by admin]
Cheers,

Stu Andrews

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11191
    • View Profile
Re: 2 radio fields on same page with same values
« Reply #7 on: August 23, 2015, 10:50:04 PM »
I agree - not a great pattern - but thanks for narrowing it down.

Cheers
Bruce