我在我的应用程序中连接到 Foursquare API。用户可以键入一个框来开始搜索场地,或者他们可以单击两个场地链接之一以用这两个场地之一填充相同的选择框。我无法让用户单击两个场所之一。这是我的代码:
JS:
function venueFormatSelection(venue) {
if ( venue.name && venue.location.address ) {
// if a user starts typing into a box, venue.name and venue.address values will pop up for them to select from. OR in the 'else' case, they can click one of either two links
else {
$("#bigdrop_set").click(function () {
return $('#bigdrop_set').attr('venue_name')
})
$("#bigdrop_set_2").click(function () {
return $('#bigdrop_set_2').attr('venue_name_2')
})
}
}
HTML:
<span class="which_venue" id="bigdrop_set" venue_name='foo' venue_data='FOO'><%= link_to(FOOOOO) %></span>
<span class="which_venue" id="bigdrop_set_2" venue_name_2='bar' venue_data_2='BAR'><%= link_to(BARRRR) %></span>
出于某种原因,“单击以填充”JS 仅在没有 .click 功能的情况下仅包含一个“返回”行时才有效:
return $('#bigdrop_set').attr('venue_name')
我的“else”语句中的代码有什么问题?谢谢!