Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery Raty获取星星数_Jquery_Callback_Parameter Passing_Jquery Callback_Raty - Fatal编程技术网

jQuery Raty获取星星数

jQuery Raty获取星星数,jquery,callback,parameter-passing,jquery-callback,raty,Jquery,Callback,Parameter Passing,Jquery Callback,Raty,我有一个带有jQuery Raty插件的简单评级系统。用户应该能够点击一个星星,输入一个很短的文本,然后点击一个按钮。该按钮具有onClick功能: <a onclick="submitReview(eventID, stadt)" data-role="button" data-theme="b">Feedback abgeben</a> 这需要此函数调用eventID、stadt和所选的星号。如何将星号传递给onClick函数?这是我的代码: <!DOCTYP

我有一个带有jQuery Raty插件的简单评级系统。用户应该能够点击一个星星,输入一个很短的文本,然后点击一个按钮。该按钮具有onClick功能:

<a onclick="submitReview(eventID, stadt)" data-role="button" data-theme="b">Feedback abgeben</a>
这需要此函数调用eventID、stadt和所选的星号。如何将星号传递给onClick函数?这是我的代码:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Single page template</title>

<link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css" />
<link rel="stylesheet" href="css/tellthedj.css" />
<link rel="stylesheet" href="css/styles.css" />
<link href='http://fonts.googleapis.com/css?family=Titillium+Web:300,600' rel='stylesheet' type='text/css'>
<script src="js/jquery-1.8.3.min.js"></script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>
</head>

<body>

<div data-role="page" id="menu"> 
<script src="js/functions.js"></script>
<script type="text/javascript" src="js/jquery.raty.js"></script>
<script>
    $(document).delegate('#menu', 'pageshow', function () {
        $('#star').raty();
        stadt = GetURLParameter('stadt');
        document.getElementById('deinestadt').value = stadt; 
        id = GetURLParameter('id');
        getEventFromId(id); 
        getEventText(id);
        eventID = GetURLParameter('id');

        $("a.button").click(function(){
        //Lets say, the Stars are next element to the <a>
        var stars = $(this).next().find("input[name='score']").val();
        submitReview(eventID, stadt, stars);
});

    });
</script>


<div data-role="panel" id="panel">
    <input id="deinestadt" style="text-align:left;" type="search" name="stadt" value="" onfocus="if(this.value=='wo bist du?') this.value=''" id="stadt" value="" />
    <br>
    <a class="menu_button" onclick="location='events.html?stadt='+stadt;" data-transition="slide" data-role="button"><img src="img/icon-map-marker.png"><span class="button_text">Events in der Nähe</span></a>
    <a class="menu_button" onclick="location='menu.html?stadt='+stadt+'&id='+eventID;" data-transition="slide" data-role="button"><img src="img/icon-house.png"><span class="button_text">Event Übersicht</span></a>
    <br>
    <a class="menu_button" onclick="location='reviews.html?stadt='+stadt+'&id='+eventID;" data-transition="slide" data-role="button"><img src="img/icon-badge.png"><span class="button_text">Bewertungen ansehen</span></a>
    <a class="menu_button" onclick="location='review.html?stadt='+stadt+'&id='+eventID;" data-role="button"><img src="img/icon-pencil.png"><span class="button_text">Event Bewerten</span></a>
    <br>
    <a class="menu_button" onclick="location='photos.html?stadt='+stadt+'&id='+eventID;" data-role="button"><img src="img/icon-photos.png"><span class="button_text">Fotos ansehen</span></a>
    <a class="menu_button" onclick="location='upload_photo.html?stadt='+stadt+'&id='+eventID;" data-role="button"><img src="img/icon-upload-photo.png"><span class="button_text">Foto hochladen</span></a>
    <br>
    <a class="menu_button" onclick="location='music.html?stadt='+stadt+'&id='+eventID;" data-role="button"><img src="img/icon-note.png"><span class="button_text">Musikwunsch</span></a>

</div><!-- /panel -->

  <!-- header -->
  <div data-role="header" data-position="fixed" id="header">
    <a href="#panel" data-role="button" data-icon="bars" data-iconpos="notext" data-inline="true"></a>
    <h1 id="headline">Event Bewerten</h1>
  </div>
  <!-- /header --> 

  <!-- content -->
  <div data-role="content"> 
    <div id="review">
        <h3>wie gefällt es dir hier?</h3>
        <div id="star"></div><br>
        <form>
            <label for="textarea-1">Schreib etwas über das Event:</label>
            <textarea cols="40" style="height:150px;" rows="10" name="textarea-1" id="textarea-1"></textarea>
        </form>
        <a onclick="submitReview(eventID, stadt)" data-role="button" data-theme="b">Feedback abgeben</a>
    </div>  
  </div>
  <!-- /content --> 

<div data-role="footer" data-position="fixed">      

</div><!-- /footer -->

</div>
<!-- /page -->

</body>
</html>

我刚刚看到这个插件有一个名为score的隐藏值,它有star的slected计数

给该类一个类似于:。按钮的类

$("a.button").click(function(){
    //Lets say, the Stars are next element to the <a>
    var stars = $(this).next().find("input[name='score']").val();
    submitReview(eventID, stadt, stars);
});
我没有测试它。没有标记很难。。。
希望对……有帮助。

我明白了!我使用了插件click的回调函数:functionscore,evt{}

这是我的标记:

<script>
    $(document).delegate('#menu', 'pageshow', function () {
        $('#star').raty({
            click: function(score, evt) {
            $("#submit_button_review").click(function(){
                submitReview(eventID, stadt, score);
            });
            }
        });
        stadt = GetURLParameter('stadt');
        document.getElementById('deinestadt').value = stadt; 
        id = GetURLParameter('id');
        getEventFromId(id); 
        getEventText(id);
        eventID = GetURLParameter('id');

    });
</script>
和按钮:

<a id="submit_button_review"  data-role="button" data-theme="b">Feedback abgeben</a>

谢谢你的帮助

如果您使用的是jQuery,为什么要使用onclick HTML属性??请改用jQuery的on方法。。。至于获取星星,您没有包含任何代码来显示星星来自何处!