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 9243947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:55:05+00:00 2026-06-18T08:55:05+00:00

When pushing a delete button, i’d like an alert to pop up to make

  • 0

When pushing a delete button, i’d like an alert to pop up to make sure the user didn’t make any mistake.

So, In codeIgniter I had this that worked well:

Button:

<td><a class='Right btn btn-danger' onClick="ConfirmMessage('news', <?php echo $new->id ?>,'news')">
                        <i class="icon-remove-sign icon-white"></i>
                    </a></td>

Javascript:

function ConfirmMessage(type, id, types) {
    if (confirm("Are you sure you want to delete this "+type+" ?")) { // Clic sur OK
     document.location.href='<?php echo site_url(); ?>/'+types+'/delete/'+id;
    }
  }

But now, with Symfony2, I can’t do this:

Button

<td><a class='Right btn btn-danger' onClick="ConfirmMessage('artist', {{ artist.id }},'news')">
                            <i class="icon-remove-sign icon-white"></i>
                        </a></td>

Javascript

function ConfirmMessage(type, id, types) {
    if (confirm("Are you sure you want to delete this "+type+" ?")) { // Clic OK
        document.location.href="{{ path('ymtest_Delete'"+types+", {'id': "+id+"}) }}";
    }
}

Since I get an error when Symfony wants to generate a url.

What could be a solution ?
Thanks

  • 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-18T08:55:06+00:00Added an answer on June 18, 2026 at 8:55 am

    you can’t write

     document.location.href="{{ path('ymtest_Delete'"+types+", {'id': "+id+"}) }}";
    

    you are mixing twig functions and javascript functions.
    Twig will be parsed and compiled on backend
    Javascript will be executed on your client side after the html page is received

    You will have to generate and assign each url type to a javascript variable.

    a more elegant way to do that would be to store your url and messages in data attributes

    <a class="Right btn btn-danger" data-url="{{ path('ymtest_EditMusician', {'id': artist.id}) }}" data-message="Are you sure you want to delete this type ?" ></a>
    

    you can now bind your event click with javscript and retrieve your data attributes values. No more javascript tests

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been pushing projects to Heroku without any issues. Just installed the Heroku_Accounts
I'm trying to delete all the markers from my map when the user presses
I'm thinking about pushing my Android app to github, but is there any information
We had a problem where the server group was pushing out incorrect drive mappings
I always had the idea to make a textarea based program, that gets the
I've been pushing my source to a Mercurial repository. Today I needed to delete
After pushing to a git repo, I got this error: [trusktr@starlancer bml]$ git push
I am pushing from my windows box to a repository cloned from an http
I am pushing 2 view controllers in to navigation stack in ApplicationDidFinishLaunching. [navigationController pushViewController:favorites
Rather than pushing a release to PyPi and GitHub, it would be easier to

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.