The easiest way is for the modal events to know what the current panel is. So we can use a global variable (though this is not recommended). Here's a jsfiddle of this: http://jsfiddle.net/FG228/5/
I added a global variable
var currentPanel=null //global variable to store current panel
$(window).resize(function(){
Assign the variable when the edit button is clicked
$(".glyphicon-edit").click(function () {
currentPanel=$(this).closest('.panel') //this refers to edit button
And finally use it when needed
//in $('.miniswitchmodal input[type=checkbox]').click()
$(currentPanel)
.toggleClass('panel-off2 panel-success',$("#modalSwitch").attr("checked"))
I also added the id modalSwitch
to the checkbox in the modal dialog for easier reference.
This should get you started, though I recommend looking into other ways of doing it, such as using javascript's ability to have functions inside functions
$('.glyphicon-edit').click(function(){
var currentPanel=this
$("#btnSave").unbind('click'); //clear the click from other panels
$("#btnSave").click(function(){
$(currentPanel).toggleClass( ... )
})
...
...
})