jQuery Knob Release函数附加参数

我正在使用jQuery Knob插件https://github.com/aterrien/jQuery-Knob

现在,我有以下jQuery旋钮初始化

loop <input type="text" value="" class="circle-rating" data-entryid=""> endloop $(function() { $(".circle-rating").knob({ 'min':0, 'max':10, 'step':1, 'width':40, 'height':40, 'fgColor':"#F59B00", 'inputColor':"#F59B00", 'displayPrevious': true, 'release' : function (v) { var entry_id = $(this).attr('data-entryid'); jQuery.post("/path/to/file/update_library_score.php", {v : v, entry_id : entry_id}, function(data) { console.log(entry_id); jQuery('#notification-general').html(entry_id); }); } }); }); 

主要问题是我在页面上有多个旋钮。 这些旋钮实际上是一个带有wordpresspost的循环。

无论如何,每个旋钮都附加到一个ID ,当你通过循环时,这个ID发生变化。

现在为了能够更新分数,我需要两个东西,即从release函数获得的旋钮value ,我还需要post_id ,我只能在循环内获得。 那么如何才能将post_id变量赋予此函数?

通常我只需添加一个button或带有onclick="my_function()但是,我不能用这个来做。抓住与你对应的$ id的最佳方法是什么?这个旋钮并将其作为参数传递给释放function?

在发布function中试试这个

 alert(this.$.attr('data-entryid')); 

在这里看演示