Skip Navigation

[Resolved] Add new Tags with Enter

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by christianS-11 6 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#606202

Hi,
is it/will it be possible that the Tags will be added after hitting the "Enter"-Key additional to clicking the "add" button?

Regards
Christian

#606363

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-01-15 at 13.13.53.png

Hi Christian

Firstly, please note that you are posting in the Community Forum for users of the free Types plugin. As a Toolset customer you can and should post in the Technical Support forum which we prioritise and where you should receive speedier service.

I assume you are talking about adding new tags in a CRED form. It is already the case that you can add new tags with the enter key in the backend when editing a post, and, no, you cannot do the same on the front end with a CRED form—without adding a little jQuery.

From the screenshot note that adding a tag-like field to a CRED form adds several inputs: a hidden version of the field itself with the field slug as its name ("taglike" in my example), the input field you actually enter the terms in ("tmp_taglike"), an input button to add new terms ("new_tax_button_taglike"), as well as the show popular section.

What you need to do is to detect when someone enters the return key when typing in the field and use that to trigger a click action on the button, as if the user had clicked it themselves.

So, in the custom JS section of your form add the following code, editing it for the slug of your custom field (i.e. replacing both instances of "taglike"):

( function( $ ) {
	$( document ).ready( function(){
		$('input[name="tmp_taglike"]').keydown(function(e) {
			if ( e.which == 13 ) {
				$('input[name="new_tax_button_taglike"]').click();
				return false;
			}
		});
	});
})( jQuery );
#606426

Perfect, thank you very much; it works.

The forum ‘Types Community Support’ is closed to new topics and replies.