PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Sep 21, 2019 2:53 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Dec 15, 2015 2:58 pm 
Offline
Forum Contributor

Joined: Thu Apr 16, 2015 7:55 am
Posts: 110
Hi There,
I'm having a jqgrid. With each row has a link for delete.

On click of the delete link, want the custom attribute I've set.
custom attribute is the primary key for row item.

On click of the URL, that particular item will be deleted from the database, and grid.

Example:
Syntax: [ Download ] [ Hide ]
<a href="#" del_val="9" onclick=delete_pipeline()>Delete</a>
 


Syntax: [ Download ] [ Hide ]

$val=$(this).data('del_val'); //--data
alert($val); //undefined

$val=$(this).attr('del_val'); //--attr
alert($val); //undefined

 

I changed del_val in double quotes:
Syntax: [ Download ] [ Hide ]
<a href="#" "del_val"="5" onclick=delete_pipeline()>Delete</a>
 


Then again I've undefined.

How do I fix it?
Thanks.


Top
 Profile  
 
PostPosted: Tue Dec 15, 2015 8:41 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA


Top
 Profile  
 
PostPosted: Wed Dec 16, 2015 7:46 am 
Offline
Forum Contributor

Joined: Thu Apr 16, 2015 7:55 am
Posts: 110


Top
 Profile  
 
PostPosted: Wed Dec 16, 2015 8:33 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
Why would you need another approach?

_________________


Top
 Profile  
 
PostPosted: Wed Dec 16, 2015 8:35 am 
Offline
Forum Contributor

Joined: Thu Apr 16, 2015 7:55 am
Posts: 110
I think I got it working:

I added class to the dynamically added anchor tags:

Syntax: [ Download ] [ Hide ]
<a href="#" class="delete_pipe" data-del-val="12" >Delete</a>
 


Syntax: [ Download ] [ Hide ]
$('body').on('click','a.delete_pipe',function(){
//do stuff here

var id=$(this).data("del-val"); //works great....

 


I found about this from:

http://stackoverflow.com/questions/1359 ... l-elements

I hope this would be fine?


Top
 Profile  
 
PostPosted: Wed Dec 16, 2015 8:40 am 
Offline
Forum Contributor

Joined: Thu Apr 16, 2015 7:55 am
Posts: 110


Top
 Profile  
 
PostPosted: Wed Dec 16, 2015 2:29 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA


Top
 Profile  
 
PostPosted: Wed Dec 16, 2015 2:38 pm 
Offline
Forum Contributor

Joined: Thu Apr 16, 2015 7:55 am
Posts: 110


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group