So I have a listview with multiple items, so when each item is clicked it will go to a detail page, but how do I fill out the detail view with dynamic contents? Specifically, how do I capture the key, which is the clicked item's inner html, and when I query some dynamic contents, how do I put them in the detail view? The methods I tried include 1) use click event for each item, but the event does not trigger, is that normal? 2) I tried the live event on the detail view page with pagebeforeshow, but it does not trigger either. Please help.
Many approaches exist to do this. Here is one idea that may help you:
In your listview, specify a data ID for each of the hyperlinks in the list item. The definitions could look like:
<li><a data-id="some-identifier">My Title</a></li>
For all the items the <li> items in the list, you then have a single click handler, which would use the data-id to initialize the detail page. The click handler would look something like this (my apologies if this is out of data, I have not recently used jQuery Mobile, so there may be an updated, better approach):
$('#my-listview-id').delegate('a', 'vclick', function () {
alert ('user selected something: ' + $(this).attr('data-id'));
});
The alert will show you the ID the user selected. So in the click handler you can update the detail page.
Related
As titled,
In my webpage, i have a jqgrid, and a button that will pop up a modal dialog that contains another jqgrid (displaying different data) on it. The problem is, the jqgrid on the modal dialog breaks the jqgrid on the page, like for example, if i set my jqgrid on the dialog to have no filter function, then it will cause the jqgrid's filter on the webpage to suddenly disappear.
Just want to know if anyone encounter such issues before?
By the way the webpage was created using Grails, so i'm not sure if this is related to Grails's resource issue or not.
It's difficult to help you because you don't posted your code. I can only to suppose that you could have id conflicts between the grid in modal dialog and the grids on the main page. I would suggest you to add idPrefix option with some non-empty unique value in the modal dialog. For example you can add idPrefix: "g1_" in the first grid and idPrefix: "g2_" in the second grid. Then the rows with ids "1", "2", "3" will be "g1_1", "g1_2", "g1_3" in the first grid and there will be "g2_1", "g2_2", "g2_3" in the second grid.
So I have a normal jQueryUI Sortable List IE: http://jqueryui.com/sortable/#default
However I would like the drag(or sort) event only to be triggered when the user clicks on a specific object inside my list item. For the sake of the example lets say the arrows in the link I provide would trigger the drag event but clicking on the text wouldn't.
Suggestions?
You can use the handle option
http://api.jqueryui.com/sortable/#option-handle
I'm starting with jQuery mobile and have some problems with my buttons.
The web application is a shopping list. It displays a list of items to shop and in the footer buttons on actions I can perform on the items.
The actions are:
increment number of items to buy
decrements number of items to buy
move item up in list
move item down in list
add new item
delete item
modify item text description
The actions are implemented in javascript and works fine. The problems I have is with controlling the buttons and the associated actions.
By experience, I have see that for the increment and decrement it is more convenient to have a button with an active state, for the other operations it is preferable to have a selected item and apply the action on the selected item when the button is pressed. When adding an item, the item would be inserted before the selected item, and if pressed when no item is selected, the new item is appended to the list.
I would also like to have 2 modes. In one mode, only the increment and decrement buttons are shown and the user can update the number of items in its list. In the other mode the user is modifying its list. It is in the second mode that the selected item is required.
I managed to associate a default action my item lists by using the .on() method as a delegate.
$('#itemList').on( "click", ".item", function(evt)
{ ctrl.doAction($(evt.currentTarget)); });
Here is the html code I use to test the first mode.
<!-- footer -->
<div data-role="footer" data-position="fixed" class="ui-bar" id="btnBar" >
Plus
Minus
</div>
<!-- /footer -->
What should I put as href value ? I don't want the page to be reloaded. In some examples I see "#".
This is how I associate the action to the button:
$('#btnPlus').on( "tap", function(evt)
{ ctrl.doAction = ctrl.increment; });
Another problem I have is that there is no feedback on the button click action. When I click a button I would expect to have it highlighted for a short time. This doesn't happen.
The browsers have also different behaviors. In firefox, the clicked button gets a blue halo apparently showing that it has the focus. But the button isn't displayed as active.
If I put "#!" as href (don't know what it means) on Android, the clicked button is shown active.
Should I use click or tap as event type ? How could I write click or tap ?
How could I implement a two state button displayed as active and inactive ?
How is an action button used : always displayed inactive and feedback when pressed ?
I solved the problem my self.
to switch between sets of buttons in the footer, I create multiple footers in my HTML document with style="display:none" in the hidden footers. The one without this will be shown. I assigned a specific id to each footer so that I can write $("#footer1").hide(); $("#footer2").show();
I have buttons to switch between footers. The footer switching event handler must be called with the "mouseup" event. This is required for it to work on the iPad and Android phones.
To change appearance, don't use .button() as suggested here. Use:
$("#myButton")
.removeClass( "ui-btn-up-a ui-btn-down-a ui-btn-hover-a" )
.addClass("ui-btn-up-b")
.attr( "data-theme", "b" );
Note: There was a bug in my code which caused desperate hair pulling
This is my scenario
I have an view(page) with list of items, a user could select single or multiple items from this page and click on a "Add to Group" button. Then a modal dialog(JQuery dialog) will be shown, from that he could select group, then press the add button. Which causes the items selected in the parent page is added to that particular group.
So, which is the best way to pass the selected items to the modal pop-up?
Though the query string ? - what happens if the no:of items selected is large, will the url support that much characters
Keep the list in the parent page in a javascript variable and return the selected group from the modal pop-up?
Or is there is any other better option?
Thanks,
Rajeesh
2a. There is no "parent" page; modal dialog is part of the same page as selected items. Therefore on "OK" function from the dialog you can go through the checked items and do whatever you want, including POSTing to the server. It's not clear from your post whether "adding items to the group" happens on the server or client
I've got a big ViewModel for a ContactViewModel with several addresses (default, invoice, delivery). This ContactViewModel I would like to edit within a DefaultAddress tab, etc. and I would like to know how to handle this without JavaScript? Is this possible?
Tell me if I'm off base here;
The way i think i'd approach this is to create a partial view which takes a list. the partial view would itterate through the list and create another partial view which is the tab.
on click of the tab i'd do a postback and store the clicked tab. this id then becomes the active tab.
when i come back to rebuild my page, the partialview for the actual tab would need to check to see if it's active and then make itself visible. if not visible then simply render nothing maybe.
This can be done with CSS. Here is an example: http://www.alistapart.com/articles/slidingdoors/
The selected tab/view will need to be rendered on the server. I can see each tab being a link, when the link is clicked the correct view and selected tab is returned.
Some of the css tabs don't work correctly in IE6. I'm not sure if the above link is one of them.