PHP Developers Network
http://forums.devnetwork.net/

undefined custom attribute Jquery
http://forums.devnetwork.net/viewtopic.php?f=13&t=142079
Page 1 of 1

Author:  publicGenome [ Tue Dec 15, 2015 2:58 pm ]
Post subject:  undefined custom attribute Jquery

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.

Author:  requinix [ Tue Dec 15, 2015 8:41 pm ]
Post subject:  Re: undefined custom attribute Jquery


Author:  publicGenome [ Wed Dec 16, 2015 7:46 am ]
Post subject:  Re: undefined custom attribute Jquery


Author:  Celauran [ Wed Dec 16, 2015 8:33 am ]
Post subject:  Re: undefined custom attribute Jquery

Why would you need another approach?

Author:  publicGenome [ Wed Dec 16, 2015 8:35 am ]
Post subject:  Re: undefined custom attribute Jquery

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?

Author:  publicGenome [ Wed Dec 16, 2015 8:40 am ]
Post subject:  Re: undefined custom attribute Jquery


Author:  requinix [ Wed Dec 16, 2015 2:29 pm ]
Post subject:  Re: undefined custom attribute Jquery


Author:  publicGenome [ Wed Dec 16, 2015 2:38 pm ]
Post subject:  Re: undefined custom attribute Jquery


Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/