Form Short code is not working in ajax content
-
Short Code of the plugin is not working on ajax content or post.
If we call post through URL it’s working correctly but when i load post through ajax short code of the form print directly instead of displaying form.
-
Hello @hiteshmandali
Please, try again after selecting the “Direct” option for the “Script load method” attribute in the setting page of the plugin (accessible through the menu option: “Calculated Fields Form”), and press the update button.
Best regards.
Hi @codepeople
Thanks for the quick response.
Method selecting the “Direct” option for the “Script load method” is not working for me.
Still showing shortcode in ajax loaded content.Thanks,
Hitesh MandaliHello @hiteshmandali
In this cases, try the following trick:
After the form’s shortcode in the page’s content, insert a “Custom HTML” block of Gutenberg with the following piece of code as its content:
<script> delete fbuilderjQuery.fbuilderGeneratorFlag; fbuilderjQuery.fbuilderjQueryGenerator(); </script>
Best regards.
Hello @codepeople
Thanks for quick reply,
After adding this script in editor after short code i am getting following error on console.
“VM1043:2 Uncaught ReferenceError: fbuilderjQuery is not defined”
And still shortcode is not working on ajax content.
Thanks & regards,
Hitesh MandaliHello @hiteshmandali
I’m sorry, but I guess that would be simpler if you send me the link to your website, and describe the process to emulate the issue.
Best regards.
Hello @codepeople
I have checked the code and found that in CPCFF_MAIN class init() method uses function is_admin() which return true during ajax call.
Note:
WordPress sets is_admin() to true for all ajax requests (front-end or admin-side). (See codex).Due to this method “_define_shortcodes” is not called.
Thanks,
Hitesh Mandali-
This reply was modified 4 years, 6 months ago by
hiteshmandali.
Hello @hiteshmandali
Please, follow the steps below:
1. Open the “/wp-content/plugins/calculated-fields-form/inc/cpcff_main.inc.php” file with the text editor of your choice.
2. Go to the piece of code:
$this->_define_shortcodes();
and move it just above the line of code:
} // End init
And please, let me know if the issue persists.
Best regards.
Hello @codepeople
Thanks for the quick reply.
I tried that but after that shortcode is not displaying but form also not displaying in ajax content.
Basic form structure is generated but form elements are not rendered.
It display like this.
<form name="cp_calculatedfieldsf_pform_1" id="cp_calculatedfieldsf_pform_1" action="?" method="post" enctype="multipart/form-data" class=""><input type="hidden" name="cp_calculatedfieldsf_id" value="5"><pre style="display:none !important;"><!--noptimize--><script>form_structure_1=[[{"form_identifier":"","name":"fieldname2","shortlabel":"","index":0,"ftype":"fnumber","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Loan Amount","predefined":"20000","predefinedClick":false,"required":false,"readonly":false,"size":"small","thousandSeparator":"","decimalSymbol":".","min":"","max":"","formatDynamically":false,"dformat":"number","formats":["digits","number","percent"],"fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname13","shortlabel":"","index":1,"ftype":"fPageBreak","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Page Break","fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname6","shortlabel":"","index":2,"ftype":"fnumber","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Residual Value","predefined":"10000","predefinedClick":false,"required":false,"readonly":false,"size":"small","thousandSeparator":"","decimalSymbol":".","min":"","max":"","formatDynamically":false,"dformat":"number","formats":["digits","number","percent"],"fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname7","shortlabel":"","index":3,"ftype":"fnumber","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Interest Rate %","predefined":"7.5","predefinedClick":false,"required":false,"readonly":false,"size":"small","thousandSeparator":"","decimalSymbol":".","min":"","max":"","formatDynamically":false,"dformat":"number","formats":["digits","number","percent"],"fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname15","shortlabel":"","index":4,"ftype":"fPageBreak","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Page Break","fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname8","shortlabel":"","index":5,"ftype":"fnumber","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Number of Months","predefined":"36","predefinedClick":false,"required":false,"readonly":false,"size":"small","thousandSeparator":"","decimalSymbol":".","min":"","max":"","formatDynamically":false,"dformat":"number","formats":["digits","number","percent"],"fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname5","shortlabel":"","index":6,"ftype":"fSectionBreak","userhelp":"Results based in the data entered above:","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"","fBuild":{},"parent":""},{"dependencies":[{"rule":"","complex":false,"fields":[""]}],"form_identifier":"","name":"fieldname4","shortlabel":"","index":7,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Monthly Payment","predefined":"","required":false,"size":"medium","eq":"prec((fieldname2*fieldname7\/1200*pow(1+fieldname7\/1200,fieldname8)-fieldname6*fieldname7\/1200)\/(pow(1+fieldname7\/1200,fieldname8)-1),2)","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","readonly":true,"formatDynamically":false,"hidefield":false,"dformat":"number","fBuild":{},"parent":""},{"dependencies":[{"rule":"","complex":false,"fields":[""]}],"form_identifier":"","name":"fieldname9","shortlabel":"","index":8,"ftype":"fCalculated","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","title":"Total Payment","predefined":"","required":false,"size":"medium","eq":"prec(fieldname4*fieldname8,2)","suffix":"","prefix":"","decimalsymbol":".","groupingsymbol":"","readonly":true,"formatDynamically":false,"hidefield":false,"fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname14","shortlabel":"","index":9,"ftype":"fhtml","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","fcontent":"\u003Cscript\u003E\n\tgetCalculatedFieldsFormCta();\n\u003C\/script\u003E","fBuild":{},"parent":""},{"form_identifier":"","name":"fieldname12","shortlabel":"","index":10,"ftype":"fhtml","userhelp":"","userhelpTooltip":false,"tooltipIcon":false,"csslayout":"","fcontent":"\u003Cdiv class=\u0022quiz-cta-shortcode hide\u0022\u003E2922\u003C\/div\u003E\n\n","fBuild":{},"parent":""}],{"0":{"title":"Lease Calculator","description":"This sample uses a more complex formula for a lease calculator. It includes the \u0022power\u0022 (pow) and \u0022precision\u0022 (prec) functions.","formlayout":"top_aligned","formtemplate":"","evalequations":1,"evalequationsevent":2,"autocomplete":1,"persistence":0,"customstyles":""},"formid":"cp_calculatedfieldsf_pform_1"}];</script><!--/noptimize--></pre> <div id="fbuilder"> <div id="fbuilder_1"> <div id="formheader_1"></div> <div id="fieldlist_1"></div> </div> </div> <div class="clearer"></div> </form>
As filed list div is blank.
Thanks,
Hitesh MandaliHello @hiteshmandali
Please, insert a “Custom HTML Block” of Gutenberg in the page’s content after the form’s shortcode with the following script:
<script> delete fbuilderjQuery.fbuilderGeneratorFlag; fbuilderjQuery.fbuilderjQueryGenerator(); </script>
Best regards.
Hello @codepeople
Thanks for the reply but that solution is not working with classic editor.
I try to add into wordpress classic editor of the post after form shortcode still getting issue.
Still form is not loaded with ajax content.
Thanks,
Hitesh Mandali-
This reply was modified 4 years, 6 months ago by
hiteshmandali.
Hello @hiteshmandali
Please, contact me directly through my private website: Contact Us
Best regards.
-
This reply was modified 4 years, 6 months ago by
- The topic ‘Form Short code is not working in ajax content’ is closed to new replies.