Stop manipulating links with jquery mobile to maintain original behavior

I have a situation where I am listing WordPress posts, and when I click on a title, jQuery is loading the single post page for me via ajax. However, I don't want this behavior - I just want the link to act normally. I have tried using the following code:

      $('article a').click(function(event){
    event.preventDefault();
    //also possible
    event.stopImmediatePropagation();
});

Unfortunately, this solution did not work. I also attempted to use data-role="none" and data-enhance="false" attributes on the <a> element, but still no luck.

One alternative could be to listen for the click event with jQuery and then manually change the window location, but this seems like a cumbersome solution.

Does anyone have any other suggestions or solutions to this problem?

Answer №1

Resolved by implementing the following code:

$('article a').click(function(event){
    event.stopImmediatePropagation();
});

Answer №2

In case you are looking for the usual functionalities of a link, have you experimented with utilizing data-ajax="false" within the a element?

<a href="#home" data-role="button" data-icon="home" data-transition="slide" data-inline="true"  data-ajax="false">Home</a>

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

Creating a scrolling sidebar in Bootstrap 4

Today I learned about CSS Bootstrap 4 and created my template with a sidebar. However, when there are many menus, I want the sidebar to show a scrollbar. I am looking for help on how to make a scrollbar appear on my sidebar template. Below are my HTML and ...

What is the best method for deleting the 'records per page' label text from datatables?

I'm trying to customize my jQuery datatables by removing the label "Records per page." I already know that "oLanguage": { "sSearch": "" } can be used to remove the search label, but is there a similar option for hiding the results per page label? ...

Loop that does not contain any duplicate fields

I recently delved into the world of advanced custom fields and I have to say, it's been a game-changer for me. However, there's one particular issue that's been giving me trouble and I could really use some guidance on it. Within the produc ...

Textview is cluttering space with Html.fromhtml that is not needed

Situation 1 Here is the code I used to display HTML-formatted text in a TextView. However, it seems to be reserving space for a link that isn't visible. holder.textView.setMovementMethod(LinkMovementMethod.getInstance()); holder.textView.setText(Htm ...

Issue with JQuery UI autocomplete functionality when using JQuery version 1.5.1

After updating to the most recent version of JQuery, I realized that my getJson calls were no longer functioning. Therefore, I have been slowly transitioning them to '$.ajax' requests and including "dataType: 'text json'". However, I r ...

Disabling the underline style on a4j:commandLink

Current Software Versions: Apache MyFaces 2.0 Rich Faces 4.3 Migration Challenge: We are in the process of upgrading from JSF version 1.2 to JSF version 2. One issue we have encountered is that there is no native support for sorting in rich:dataTable. ...

the else/if statement executes only on the first run

In my current code, when the user inputs a color that matches any of the colors in the array, it will add that color class to the main div. The issue I'm facing is that my else-if statements only run once. If you input the same color again, it won&ap ...

keep the color of the link after clicking until a different link is clicked

At the bottom of every post on my website, there are 3 buttons: "Written By", "Related Post," and "In This Category": SoCatchy! I'm looking to have each button change color when clicked, and stay that way until another link is clicked. Here is the c ...

Removing a single div box causes a ripple effect on another div box, despite their lack of connection

I'm struggling to remove the white box underneath the "features" section on this website (). The structure of the div is quite simple: <div class="donatenew"></div> and here's the CSS: .donatenew { width:100%; background: #f8f ...

Retrieving XML data using jQuery and Ajax

Hey there! I am looking to extract information from an XML file. Below is the HTML code snippet: <!DOCTYPE html> <html> <head> <script type="text/javascript"> var xml; $(document).ready(function(){ ...

What is the reasoning behind utilizing the "&" selector in CSS?

.navigation { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: translation: all ease 0.25s; &.expand { transform: translateX(0); } } JavaScript file: $(document).ready(func ...

Items positioned to the left will not overlap

Having trouble with floating elements? Need to ensure that box 3 aligns under box 1 when resizing the browser window? Use this HTML template: <div class="box"> <p>box 1</p> <p>box 1</p> <p>box 1</p> & ...

What is the easiest way to simulate the Ctrl+C key event using jQuery?

I need to programmatically simulate pressing Ctrl+C in order to copy text from a page. My initial attempt looked like this: $('#codetext').click( function() { $("#codetext").trigger({ type: 'keydown', which: 99 }); } Her ...

Can <option> tags be arranged side by side using CSS?

Here is a form I am working with: <form action="file.php" method="GET"> <input type="hidden" name="page"> <select> <option>Text 1</option> <option>Text 2</option> <option>Text 3 ...

Clearing HTML input connected to PHP and AJAX: A handy guide

Is there a way to automatically clear my HTML input after pressing the enter key? I have a complex program that utilizes AJAX and PHP. I attempted to use jQuery's $("#txt").val('') function, but it clears every letter typed (I only want to c ...

Inject environment variable into SCSS file while using webpack

I'm new to webpack and I need help with reading a specific value, which is the env variable from the webpack.config.js file, in a sass file. This will allow me to have different CSS styles based on the environment. For example: If the env is set to ...

Challenge: Integrate jQuery into Wordpress while converting a Bootstrap template

I am facing an issue with loading jQuery files from a Bootstrap template while converting it into a Wordpress theme. Despite trying various methods of enqueuing scripts in my functions.php file and even de-registering jQuery, the problem persists. Upon in ...

By combining TCPDF with basic HTML, you can easily generate a detailed table of contents

Is there a way to generate a table of contents when printing HTML to PDF using TCPDF? Here is an example code snippet: $html = '<h1>Hello</h1> How are you? <h2>Answer</h2> I am well, thanks'; // ... etc. Long HTML documen ...

What is the best way to assign a dynamic width to a block element?

In my project, I am working with 30 elements that have the class .lollipop and are styled with line-height: 30px; height: 30px;. <a class="lollipop">Random text</a> <a class="lollipop">Random text longer</a> <a class="lollipop"& ...

Using Rails to render a partial with jQuery for a loop function

I am trying to include a partial multiple times in my view with different parameters. I have a search form that returns project data in JSON format using Ajax. Now, I want to use a jQuery function to get the project and display it in the view. $.ajax({ ...