• Hello, first of all, thanks for this good plugin!

    But not everything is perfect for me, when I open the page, fill the form and send it, it’s all ok, ajax clear the fields and say that was sent, but if I try to fill and send it again the Dynamic Texts goes BLANK.

    What I see is if I don’t reload the page after I submit it once, these values are not being filled for the next submit…

    I’m using:
    [dynamictext evento id:evento class:hidden “CF7_get_post_var key=’title'”]
    [dynamictext link_evento id:link_evento class:hidden “CF7_URL”]

    Thanks in advance!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author sevenspark

    (@sevenspark)

    Yup, that makes sense. Contact Form 7’s JS functionality automatically clears the values after form submission. CF7 DTX is pure PHP right now, so it doesn’t have any control over any changes that are made client-side.

    If you wanted to keep certain fields from clearing, you could overwrite the clearform function, which looks like this:

    $.fn.clearForm = function() {
    	return this.each(function() {
    		$('input,select,textarea', this).clearFields();
    	});
    };

    For example, to keep it from clearing hidden fields (those made with [dynamichidden]), you could write something like this jQuery function (untested):

    $.fn.clearForm = function() {
    	return this.each(function() {
    		$('input,select,textarea', this).not('input:hidden').clearFields();
    	});
    };

    Assuming you loaded it after CF7’s javascript, this should overwrite the function I believe.

    I’ll look into including this functionality in the next release of CF7 DTX ??

    By the way, instead of applying the ‘hidden’ class to your fields, it is probably better to use the dynamichidden tag (available in the latest version of CF7 DTX).

    Hope that helps,

    Chris

    Thread Starter LeoStorch

    (@leostorch)

    Thanks Chris, this help me a lot! I don’t know much about Javascript, how can I change your function to DON’T clear the fields with an specific class, like “dontclear”?

    I tried it:

    $.fn.clearFields = $.fn.clearInputs = function() {
    	return this.each(function() {
    		var t = this.type, tag = this.tagName.toLowerCase();
    		if (t == 'text' || t == 'password' || tag == 'textarea') {
    			if($(this).hasClass('dontclear')){
    				this.value = this.value;
    			} else {
    				this.value = '';
    			}
    		}
    		else if (t == 'checkbox' || t == 'radio') {
    			this.checked = false;
    		}
    		else if (tag == 'select') {
    			this.selectedIndex = 0;
    		}
    	});
    };

    But isn’t working…

    Thanks!

    Plugin Author sevenspark

    (@sevenspark)

    I would just change the selector in the clearForm function:

    $.fn.clearForm = function() {
    	return this.each(function() {
    		$('input,select,textarea', this).not('.dontclear').clearFields();
    	});
    };

    The .not() removes elements with the dontclear class from the set of elements to clear.

    Just make sure the script with this function runs after the CF7 script, and inside a jQuery(document).ready()

    Thread Starter LeoStorch

    (@leostorch)

    I was trying to edit the original jquery.form.js from CF7, should work, right?

    $.fn.clearForm = function() {
    	return this.each(function() {
    		$('input,select,textarea', this).not('.dontclear').clearFields();
    	});
    };

    I tried that on the original JS and didn’t work. =/

    Plugin Author sevenspark

    (@sevenspark)

    Hi Leo,

    I’m currently away with limited access, but I’ll add this to my do list to figure out, hopefully this week. I’ll let you know what I figure out.

    Thread Starter LeoStorch

    (@leostorch)

    Don’t worry sevenspark, I found the problem. Even adding this code the form keeps being cleared. I hed to remove the “.resetForm()” from scripts.js.

    if (1 == data.mailSent) {
    		$(data.into).find('form').resetForm().clearForm();

    Now it’s working. Sadly I had to change the original code.

    Thanks!

    I’ve removed the .resetForm() from the CF7 scripts.js as well, but it didn’t solve the refresh issue for me. All the fields, including the dynamic fields still refresh. Any ideas?

    Anyon knows how to add a dynamic textarea??

    like [dinamictext xxx “CF7_GET key=’item_link'”]

    ???

    Anyon knows how to add a dynamic textarea??
    
    like [dinamictext xxx "CF7_GET key='item_link'"]
    
    ???

    I concur.

    Plugin Author sevenspark

    (@sevenspark)

    @lassepappa, @paul Sputnik,

    CF7 DTX doesn’t currently support text areas, only text inputs.

    If you’re referring to text inputs and are having trouble with that code, you should make sure you are using the correct tag names – e.g., it’s “dynamictext” not “dinamictext” ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Contact Form 7 Dynamic Text Extension] Ajax Problem’ is closed to new replies.