8577

prevent laravel link_to_action to perform on double click

Question:

In my laravel project controller i wrote a code for approve and reject appointments. on rejecting the appointment the entry will be deleted from database and redirect again to the listing table.

i used this code in reject section

html_entity_decode(link_to_action('AdminController@getAtoggle', '<img src="'.$icon2.'"alt=asknow width=20 height=20/>',array($data['appointment_id'],2),array('title'=>'Click Me For Reject','ondblclick' => "event.preventDefault();")));

But still when double clicks " Trying to get property of non-object " error is showing. I clearly know this occurs because , on first click the entry is deleted from database so the second click there is no entry to delete in db. but in case the user double clicks i don't want to show them this error message or 404 page.

so is there any way to prevent double clicks. i tried "alert" in "ondblclick" but that shows both alert and error page.

Answer1:

I think the problem is you're trying to use event before it's been initialised.

Try move the code from the <a> tag to your JS files, try this jQuery

$( "#target" ).dblclick(function(event) { event.preventDefault(); });

I'm passing in event into the callback so you can run preventDefault().

Recommend

  • MVC3. Ajax Confirmation comes twice
  • In MVC/Razor, how can you open a new view instead of as a partial view?
  • Adding custom gesture to iCarousel items
  • Load in models dynamically in Laravel 5.1
  • How to show underscore (shortcut) without holding Alt?
  • jParallax trouble
  • window.onbeforeunload in javascript
  • File loader changed image file name but not the file name in HTML file
  • Is it better to use the “hidden” CSS attribute or fetch each set of new images?
  • Python PIL to extract number from image
  • Outputting SharePoint Hyperlink Column as URL
  • Disable Kendo Autocomplete
  • How to view images from protected folder with php?
  • Display images in Django
  • DomPDF {PAGE_NUM} not on first page
  • R - Combining Columns to String Based on Logical Match
  • how to do an event when i swipe from fragment to the other
  • Linq Objects Group By & Sum
  • Deselecting radio buttons while keeping the View Model in synch
  • Javascript simulate pressing enter in input box
  • How reduce the height of an mschart by breaking up the y-axis
  • Resize panoramic image to fixed size
  • How to add date and time under each post in guestbook in google app engine
  • SSO with signing and signature validation doesn't work
  • How to show dropdown in excel using jrxml (jasper api)?
  • Importing jscolor library in angular 2
  • Release, debug version and Authorization Google?
  • Websockets service method fails during R startup
  • Alternatives to the OPTIONAL fallback SPARQL pattern?
  • How to get next/previous record number?
  • Apache 2.4 - remove | delete | uninstall
  • Proper way to use connect-multiparty with express.js?
  • Trying to get generic when generic is not available
  • embed rChart in Markdown
  • How to get Windows thread pool to call class member function?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal