Robert Benedetto
Robert Benedetto

Reputation: 1718

Javascript in Datatables cell

I am using Jquery Datatables, and have to have confirmation scripts in certain cells. However, since the use of ' causes the script to not fire (' within '), how can I get around this? Example below (the onclick event won't fire, I get sent to the link immediately).

var dataSet = [["<a href='member_search.aspx' onclick='return confirm('Please confirm?'); return false;' class='btn btn-danger btn-xs'>radera</a>", "Test1", "Test1", "Test1", "<a href='member_details.aspx'>info</a>"]]

Upvotes: 1

Views: 45

Answers (3)

ITSGuru
ITSGuru

Reputation: 194

i will use this code and run properly , plz try ..

OnClientClick='<%# string.Format("javascript:return confirm(\"Do you want to do this : {0}\")", Eval("ID")) %>'>

Thank you

Upvotes: 0

davidkonrad
davidkonrad

Reputation: 85558

Just use &quot; :

onclick='return confirm(&quot;Please confirm?&quot;); return false;' 

http://jsfiddle.net/0f9Ljfjr/962/

Upvotes: 0

Tomer
Tomer

Reputation: 17940

You need to escape the extra quotes:

onclick='return confirm(\'Please confirm?\')

Upvotes: 1

Related Questions