Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labels need the "For" attribute #141

Open
vhalik opened this issue May 3, 2013 · 3 comments
Open

Labels need the "For" attribute #141

vhalik opened this issue May 3, 2013 · 3 comments

Comments

@vhalik
Copy link

vhalik commented May 3, 2013

Is there a plan for labels to have the for attribute? Need a quick way to associate which label is associated to which element.

@elclanrs
Copy link
Owner

elclanrs commented May 6, 2013

What do you mean? If you add the for attribute to the label and an id to your input it should work just fine, or am I missing something here?

@vhalik
Copy link
Author

vhalik commented May 8, 2013

Correct me if I am wrong. I did not find anywhere in your documentation
about ideal forms auto creating a for attribute. I tried this:

This is within the createNewField function
var newFields = [{
name: 'field' + labelCount,
label: 'Label' + labelCount,
'for': 'field' + labelCount,
type: element.attr('id'),
list: ['Label' + labelCount]
}];

Which didn't work, obviously. So what I ended up doing was:

$('.ideal-label')[labelCount].setAttribute('for', 'field' + labelCount);
Above was done while creating the element and the id was still active
within the function.

Here is the catch. When I make a change after I created the new field I no
longer have that label with the for attribute since ideal forms overwrites
it. So I had to do this to compensate.

This is within the editField function
$workspaceForm.addFields(editField);
$workspaceForm.removeFields(fieldObject['oldid']);

    var labelText =

$('#'+document.getElementById('FormBuilder_idType').value).parent().prevAll('label').text();
var labelFor =
$('#'+document.getElementById('FormBuilder_idType').value).parent().prevAll('label');

    labelFor.attr('for',

document.getElementById('FormBuilder_idType').value);

Is there an easier way of setting the for attribute for the label while
creating the element through ideal forms?

On Mon, May 6, 2013 at 1:57 AM, elclanrs [email protected] wrote:

What do you mean? The label is just html, if you add the for and an id to
your input it should work just fine.


Reply to this email directly or view it on GitHubhttps://github.com/elclanrs/jq-idealforms/issues/141#issuecomment-17470089
.

@vhalik
Copy link
Author

vhalik commented May 8, 2013

I totally forgot to tell why I had to do this. I am doing this because when
I retrieve the ideal forms input settings to edit it will not retrieve the
innerHTML of the label. The innerHTML will always be different from the
name of the input which is the actual ID of the input. I was looking for
something like addFields but called getFields in order to get the label
text. I tried

$myform.setFieldOptions( 'username', { filters: 'username' } )

but that didn't do what I thought it would do.

On Wed, May 8, 2013 at 11:32 AM, Tim Soliday [email protected] wrote:

Correct me if I am wrong. I did not find anywhere in your documentation
about ideal forms auto creating a for attribute. I tried this:

This is within the createNewField function
var newFields = [{
name: 'field' + labelCount,
label: 'Label' + labelCount,
'for': 'field' + labelCount,
type: element.attr('id'),
list: ['Label' + labelCount]
}];

Which didn't work, obviously. So what I ended up doing was:

$('.ideal-label')[labelCount].setAttribute('for', 'field' + labelCount);
Above was done while creating the element and the id was still active
within the function.

Here is the catch. When I make a change after I created the new field I no
longer have that label with the for attribute since ideal forms overwrites
it. So I had to do this to compensate.

This is within the editField function
$workspaceForm.addFields(editField);
$workspaceForm.removeFields(fieldObject['oldid']);

    var labelText =

$('#'+document.getElementById('FormBuilder_idType').value).parent().prevAll('label').text();
var labelFor =
$('#'+document.getElementById('FormBuilder_idType').value).parent().prevAll('label');

    labelFor.attr('for',

document.getElementById('FormBuilder_idType').value);

Is there an easier way of setting the for attribute for the label while
creating the element through ideal forms?

On Mon, May 6, 2013 at 1:57 AM, elclanrs [email protected] wrote:

What do you mean? The label is just html, if you add the for and an id
to your input it should work just fine.


Reply to this email directly or view it on GitHubhttps://github.com/elclanrs/jq-idealforms/issues/141#issuecomment-17470089
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants