我订阅已发布的馆藏时,何时可以传递论据?
我正在发布我的收藏:
Meteor.publish('recent-posts', function (options) {
var limit = options.limit;
return Posts.find({}, {sort: {date: -1}, limit: limit});
});
在我的路线文件中,我可以像{limit: 5}
这样传递options
,并且它有效:
...
waitOn: function () {
return Meteor.subscribe('recent-flights', {limit: 5});
}
...
令我困惑的是,这也有效:
...
waitOn: function () {
return Meteor.subscribe('recent-posts', {date: this.params.date});
}
...
第二个示例订阅了所有具有特定日期值的帖子。
为什么会这样?好像我将{date: this.params.date}
作为options
传递。但我在date
中没有对Meteor.publish
进行任何定义。
答案 0 :(得分:1)
<asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource2" OnItemDataBound="ListView1_ItemDataBound" OnItemCommand="ListView1_ItemCommand" DataKeyNames="HotelID">
<EditItemTemplate>
<li style="">HotelID:
<asp:TextBox ID="HotelIDTextBox" runat="server" Width="200px" Text='<%# Bind("HotelID") %>' />
<br />
HotelName:
<asp:TextBox ID="HotelNameTextBox" runat="server" Text='<%# Bind("HotelName") %>' />
<br />
Country:
<asp:TextBox ID="CountryTextBox" runat="server" Text='<%# Bind("Country") %>' />
<br />
Town:
<asp:TextBox ID="TownTextBox" runat="server" Text='<%# Bind("Town") %>' />
<br />
Image:
<asp:TextBox ID="ImageTextBox" runat="server" Text='<%# Bind("Image") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
Country1:
<asp:TextBox ID="Country1TextBox" runat="server" Text='<%# Bind("Country1") %>' />
<br />
Rooms:
<asp:TextBox ID="RoomsTextBox" runat="server" Text='<%# Bind("Rooms") %>' />
<br />
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</li>
</EditItemTemplate>
<EmptyDataTemplate>
No data was returned.
</EmptyDataTemplate>
<InsertItemTemplate>
<li style="">HotelID:
<asp:TextBox ID="HotelIDTextBox" runat="server" Text='<%# Bind("HotelID") %>' />
<br />
HotelName:
<asp:TextBox ID="HotelNameTextBox" runat="server" Text='<%# Bind("HotelName") %>' />
<br />
Country:
<asp:TextBox ID="CountryTextBox" runat="server" Text='<%# Bind("Country") %>' />
<br />
Town:
<asp:TextBox ID="TownTextBox" runat="server" Text='<%# Bind("Town") %>' />
<br />
Image:
<asp:TextBox ID="ImageTextBox" runat="server" Text='<%# Bind("Image") %>' />
<br />
City:
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' />
<br />
Country1:
<asp:TextBox ID="Country1TextBox" runat="server" Text='<%# Bind("Country1") %>' />
<br />
Rooms:
<asp:TextBox ID="RoomsTextBox" runat="server" Text='<%# Bind("Rooms") %>' />
<br />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</li>
</InsertItemTemplate>
<ItemSeparatorTemplate>
<br />
</ItemSeparatorTemplate>
<ItemTemplate>
<li style="">
<table style="width: 100%;">
<tr style="width: auto; background-color: white;">
<td align="center">
<div id="pageone" data-role="main" class="ui-content">
<a href="#myPopup" data-rel="popup" data-position-to="window">
<img src='<%# Eval("Image")%>' alt="Skaret View" style="height: 116px; width: 311px"></a>
<div data-role="popup" id="myPopup" data-transition="flip" data-overlay-theme="b">
<p>This is my picture!</p>
<a href="#pageone" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a><img src='<%# Eval("Image")%>' style="width: 800px; height: 400px;" alt="Skaret View">
</div>
</div>
<td>
<asp:Label ID="HotelNameLabel" runat="server" Text='<%# Eval("HotelName")%>' Font-Underline="true" />
<br />
<asp:Label ID="TownLabel" runat="server" Text='<%# Eval("Town")%>' />
,
<asp:Label ID="CountryLabel" runat="server" Text='<%# Eval("Country")%>' />
<br />
<asp:Label ID="HotelIDLabel" runat="server" Text='<%# Eval("HotelID")%>' Visible="false" />
</td>
<br />
<br />
<td align="right">
<asp:Button ID="Button1" runat="server" CssClass="styled-button-2" Text="Book Now" PostBackUrl='<%#"~/BookHotel.aspx?HotelID=" + Eval("HotelID")%>' />
</td>
</tr>
</table>
</li>
</ItemTemplate>
<LayoutTemplate>
<ul id="itemPlaceholderContainer" runat="server" style="list-style: none">
<li runat="server" id="itemPlaceholder" />
</ul>
<div style="">
</div>
</LayoutTemplate>
<SelectedItemTemplate>
<li style="">HotelID:
<asp:Label ID="HotelIDLabel" runat="server" Text='<%# Eval("HotelID")%>' />
<br />
HotelName:
<asp:Label ID="HotelNameLabel" runat="server" Text='<%# Eval("HotelName")%>' />
<br />
Country:
<asp:Label ID="CountryLabel" runat="server" Text='<%# Eval("Country")%>' />
<br />
Town:
<asp:Label ID="TownLabel" runat="server" Text='<%# Eval("Town")%>' />
<br />
Image:
<asp:Label ID="ImageLabel" runat="server" Text='<%# Eval("Image")%>' />
<br />
City:
<asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City")%>' />
<br />
Country1:
<asp:Label ID="Country1Label" runat="server" Text='<%# Eval("Country1")%>' />
<br />
Rooms:
<asp:Label ID="RoomsLabel" runat="server" Text='<%# Eval("Rooms") %>' />
<br />
</li>
</SelectedItemTemplate>
</asp:ListView>
中的任何内容都不会导致这种行为,至少从源代码中可以看出。我还在一个“干净”的流星实例中测试了你的例子。它没有像你描述的那样表现。所以它必须是你的代码中的一些东西。也可能是,你没有正确描述你的问题。
我还注意到你在你的例子中使用了两个不同的订阅; Meteor
和recent-posts
。所以这可能是你混乱的根源。