Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery setting options after init

I know one can set plugin options, after things are set. But I'm not quite sure how to do it. So I created a simple jquery UI example, using the draggable(), with zIndex option already set. So, if I click the link I created, I want to change the zIndex option to another integer. Here's the link I am work from: http://jqueryui.com/demos/draggable/#option-zIndex

<script>
$(function() {

  $( ".dragimgs" ).draggable({ zIndex: 2700 });


});
</script>

<img class="dragimgs" src="someimg.png" />

<a id="clickme">Click To Change zIndex</a>

So the question is how do I reset the zIndex (or any available option), dynamically. I am assuming that a js function or some onclick event can be utilized, but I honestly don't know how.

like image 966
coffeemonitor Avatar asked May 25 '11 04:05

coffeemonitor


1 Answers

You can use .draggable( "option" , "optionName" , value ) to change your zIndex

Putting that together with the zIndex it would look like the following...

$("#clickme").click(function() {
    $(".dragimgs").draggable("option", "zIndex", 1000);
});

Example on jsfiddle

like image 116
Mark Coleman Avatar answered Oct 12 '22 07:10

Mark Coleman