Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7986519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:52:39+00:00 2026-06-04T11:52:39+00:00

I have been building a dynamic form in my Zend Framework application using Jquery

  • 0

I have been building a dynamic form in my Zend Framework application using Jquery and Ajax but i’ve run into a problem. For some odd reason Jquery will not work on my page unless i add one of the standard Jquery object like the datePicker.

Whenever I add the datepicker my code works perfectly fine, when I remove the datepicker it gives the error that the $(document).ready(function() variable is undefined. This in itself is correct considering jquery isn’t being loaded and thus the variable makes no sense to the browser.

I have the library, bootstrap and the echo $this->Jquery(); all set up appropriately otherwise the date picker wouldn’t function, and when the datepicker is present it and the other code work perfectly suggesting it is all properly set up.

Has anyone else run into the issue of Jquery not loading properly?

My code in the bootstrap :

protected function _initViewHelpers()
{
    $view = new Zend_View();
    $view->addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewRenderer->setView($view);

And my code in the layout :

<?php  
echo $this->jQuery();
echo $this->layout()->content; 
?>

My application.ini also has the autoloaderNamespaces[] = "ZendX" line

And here is the jquery code in my view :

<p>All fields are required.</p>

<?= $this->form; ?>

<script type="text/javascript">

$(document).ready(function() {

  $("#addElement").click( 
      function() { 
          ajaxAddField();
       }
    );

  $("#removeElement").click(
      function() {
          removeField();
      }
    );
  }
);

// Get value of id - integer appended to dynamic form field names and ids
var id = $("#id").val();

// Retrieve new element's html from controller
function ajaxAddField() {
  $.ajax(
    {
      type: "POST",
      url: "<?=$this->url(array('action' => 'newfield', 'format' => 'html'));?>",
      data: "id=" + id,
      success: function(newElement) {

        // Insert new element before the Add button
        $("#addElement-label").before(newElement);

        // Increment and store id
        $("#id").val(++id);
      }
    }
  );
}

function removeField() {

  // Get the last used id
  var lastId = $("#id").val() - 1;

  // Build the attribute search string.  This will match the last added  dt and dd elements.  
  // Specifically, it matches any element where the id begins with 'newName<int>-'.
  searchString = '*[id^=newName' + lastId + '-]';

  // Remove the elements that match the search string.
  $(searchString).remove()

  // Decrement and store id
  $("#id").val(--id);
}

</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:52:40+00:00Added an answer on June 4, 2026 at 11:52 am

    try enabling it explicitly

    $this->jQuery()->enable();
    

    And also set this at last line in _initViewHelpers()

    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been building a new application using my current understanding of domain driven
I am building a web application and have been told that using object oriented
I'm exploring package building on Windows 7 but have been running into trouble after
i have been building websites using vs 2008 (mostly asp.net mvc, jquery and webforms).
I have been building a game for a while (nearly done) - But the
I have been involved in building a custum QGIS application in which live data
I have been working on building my first CSS site using divs and am
I'm using qmake for building a project of mine. I have been trying to
I have been building my own carasol over the past few days. My Jquery
I have been asked to look into dynamic web page development, and there appears

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.