Issue with Foundation5 reveal not triggering properly when invoked through JavaScript

Recently updated Zurb's Foundation4 to version 5 and encountered an issue with the reveal functionality. Despite starting fresh with a new framework download, I am still unable to get the reveal feature to work properly as it did in version 4.

Here is the code I have tried:

<!doctype html>
<html class="no-js" lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Foundation | Welcome</title>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.2/css/foundation.min.css" />
    <script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.7.0/modernizr.min.js"></script>
  </head>
  <body>

    <h1>Reveal Test</h1>
    <p><a href="/server.php?id=1234" data-reveal-id="myModal1" data-reveal-ajax="true">Load via a href ajax (calling /server.php) - works!</a></p>
    <p><a id="fire-via-js">Load via javascript</a></p>

    <div id="myModal1" class="reveal-modal" data-reveal><a class="close-reveal-modal">&#215;</a></div>
    <div id="myModal2" class="reveal-modal" data-reveal><a class="close-reveal-modal">&#215;</a></div>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.0.2/js/foundation.min.js"></script>
    <script>
      $(document).foundation();
      $(document).ready(function() {

            // url with custom callbacks
            $('#fire-via-js').click(function() {
                $('#myModal2').foundation('reveal', 'open', {
                    url: '/server.php?id=5678',
                    success: function(data) {
                        alert('modal data loaded');
                    },
                    error: function() {
                        alert('failed loading modal');
                    }
                });
            });

        });
    </script>
  </body>
</html>

The server.php file being called simply contains:

<?php

echo "hello world...<br />";

if(isset($_GET['id'])) {
    echo "got the id : ". $_GET['id'] ."<br />";
}

Although the documentation states that "Ajax-based Reveal modals can also be opened via JavaScript," when attempting to load it through JavaScript, the output from the PHP file does not display in the modal.

If there is a basic oversight on my part after spending hours trying to transition old calls to the new system, any guidance would be greatly appreciated!

Answer №1

As per Damien's observation, the recent update of Foundation 5 has successfully addressed this particular issue. I can confirm that I have downloaded and verified it on February 25, 2014.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I update the state with the value of a grouped TextField in React?

Currently working on a website using React, I have created a component with grouped Textfields. However, I am facing difficulty in setting the value of these Textfields to the state object. The required format for the state should be: state:{products:[{},{ ...

Using JQuery within Angular 4 is a valuable tool for enhancing the functionality

As a newcomer to Angular, I am experimenting with using jQuery alongside Angular 4. In my search for information, I stumbled upon this question on Stack Overflow. Inside the question, there was an example provided that can be found here. However, when att ...

Convert JavaScript objects into HTML format

Alright, I've got some JavaScript that's fetching data from a JSON file through a URL. Now, my goal is to convert each object (author_name, rating, author_url) into JavaScript IDs so that I can easily reference them in my HTML. For instance: &l ...

Socket.io continuously refreshing and updating multiple instances

Incorporating socket.io into a small React application, I configured all the listeners within the "componentWillMount" method. See the code snippet below for reference: componentWillMount() { const socket = io(); socket.on('update', f ...

The concealment of the container is ineffective when attempting to hide it until all cached images are

My website has a background and a main container. I wanted to hide the container until the entire page had loaded, so I included #cover{opacity:0} at the beginning of the page and $(window).load(function() { $('#cover').css('opacity&apo ...

Update the image source every few seconds

I am attempting to show the same image in both gif (animated) and jpeg formats. I am updating the src every few seconds. After checking in the developer tools, it seems that the src has been modified, but the gif does not appear to be animating. setInter ...

Using PHP to pass an Ajax request with a variable and retrieving a response with a distinct

I am in the process of creating a simplified referral system. $(document).ready( function() { document.getElementById("getref").onclick = function setref() { $.ajax({ url: 'newref.php&apo ...

Can Firebase data be updated in real-time in a Vue app?

Utilizing Firebase for Authentication and integrating a database into a Vue app, my current task involves monitoring changes within a 'friends' collection specific to a user. The objective is to seamlessly display the list of friends while refle ...

Displaying a component in a router view based on specific conditions

Currently, I am delving into the world of Vue3 as a newcomer to VueJS. In my project, there is an App.vue component that serves as the default for rendering all components. However, I have a Login.vue component and I want to exclude the section when rende ...

MetaMask RPC error encountered: execution failed with code -32000 and message stating "execution reverted"

While working on a DApp project that involves using React and Solidity with an ERC20 contract, I have successfully deployed my smart contract on Rinkeby. I am able to interact with the contract using name() and symbol(). However, I encountered an issue whe ...

PHP loop causing malfunction in jQuery Tooltip feature

I am trying to enhance my website with tool-tips, and I found this useful code snippet at In order to create table rows <tr>, I have implemented a while loop. The structure of my tool-tip <div> is as follows: <td class="maandgem">&e ...

Navigating the loading of information with fetch and React Hooks

As a newcomer to React and still learning JavaScript, I am facing a challenge with handling useEffect alongside an asynchronous function. My goal is to fetch data from an API and render a quote in the paragraph with id of text, along with the author's ...

The deletion of elements in an array using $timeout is experiencing issues with functionality

After 5 seconds, the directive notification should automatically delete itself. However, there seems to be an issue where some elements are missed and others get deleted more than once. Each notification has a unique identifier property. Thank you for any ...

Each time the toggle is switched, an additional AJAX request is sent to the PHP document

I've been working on a function that sends data to a PHP file, which then processes the data. The PHP part works fine, but I'm having issues with the jQuery side of things. Each time I click on a ".work" element and trigger the toggle function, a ...

Contact form repair completed - Messages successfully delivered

I am facing an issue with the contact form on my HTML landing page. Currently, when you click the 'Submit' button, it redirects to a new PHP page displaying 'Success'. Is there a way to make it so that upon clicking 'Submit' a ...

Mastering the art of correctly utilizing JavaScript promises in the context of Ionic and Cordova

Here is the code snippet for Login.ts: export class LoginPage { public version:string; constructor(public navCtrl: NavController, public navParams: NavParams, private appVersion: AppVersion) { this.appVersion.getVersionNumber().then((val) => { ...

What is the process for implementing a decorator pattern using typescript?

I'm on a quest to dynamically create instances of various classes without the need to explicitly define each one. My ultimate goal is to implement the decorator pattern, but I've hit a roadblock in TypeScript due to compilation limitations. Desp ...

Transforming an MVC4 Web API App into a Phonegap Android App

element, I have created an MVC4 Web API application that features an Api Controller and a Code-First EF5 database. Additionally, I have implemented several JavaScript functions to enhance the functionality of my app, including Ajax Calls for the Web Api S ...

The Firebase transaction encountered a null value during reading, despite there being data present at the specified path

After working with Firebase transactions for some time, I've come to understand that occasionally the data read can be null until it is obtained from the server and committed. However, I am encountering a peculiar scenario where the transaction reads ...

Is the renderer.setSize in Three.js calculated as a percentage of the screen size?

Is it possible to calculate the renderer.setSize based on a percentage of the screen? For instance, could I set my frame to be 80% of the device width and 80% of the device height? ...