Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery data() with multiple parameters?

I want to add data variables to an element before causing a specific behavior, but this may require adding more than one data parameter. How can I accomplish this?

     $("#dlg_box").data("r_redirect","index.php").dialog("open");
like image 694
Hosea Kambonde Avatar asked May 21 '13 13:05

Hosea Kambonde


1 Answers

You can do it like this:

var data = $("#dlg_box").data();   
data.r_redirect = "index.php";  
data.foo = "bar";

$("#dlg_box").dialog("open");

This was taken from here.

To retrieve your values:

$("#dlg_box").data("r_redirect");
$("#dlg_box").data("foo");
like image 116
97ldave Avatar answered Sep 30 '22 17:09

97ldave