Hello!
1) We reported a bug.
2) Regarding click on right list part, you can do search not inside element you clicked on, but on entire listitem pre$(this).closest("li").html()/preinstead pre$(this).html()/pre
Hello!
1) We reported a bug.
2) Regarding click on right list part, you can do search not inside element you clicked on, but on entire listitem pre$(this).closest("li").html()/preinstead pre$(this).html()/pre
Thank you, Maryna.
This doesn't go exactly with the title of this post, regarding the variable name of the counter value, but it goes with what is immediately above this post.
The original poster was wanting to map an id to the counter value and then access it via javascript. The reply said that component is not available.
If your list item already has labels in it, then you can simply add an input component, uncheck visible to make it hidden, then access that. However, if you use a split button list, adding a label or input makes it an "unsplit" button.
Here is the solution I used for a split button.
In my REST service results, I map the information I want to show on the left side of the button to the Text property of the list item. In that information I include an html comment. I am wanting both an ID and a name, so this example has both.
Here is the comment I include in the information returned by my REST service:
pre<!-- userid=1234 fullname=Joe Contact --/pre
In the events for the list item button, I have it run this javascript:
pre
var txt = $(this).closest("li").html();
txt.match(/ userid=(\d) fullname=(.) --/);
var userid = RegExp.$1;
var fullname = RegExp.$2;
localStorage.setItem('popupheader',fullname);
localStorage.setItem('userid',userid);
/pre
I don't need to match the opening part of the comment. If all you want is an ID, then remove the parts about fullname.
In my app, when clicking the button on the right of the list item, a popup opens showing a contact's information. The javascript has already put the name and userid in local storage variables, in in the popup, when the page shows, it puts the value of popupheader into the header text. And when the popup shows, it calls a REST service which gets the userid from the local storage variable in the request. Fyi, my list item shows some basic information about the contact - name, email, phone. The popup shows all the information. Therefore I already have the name in the list item. I could just as easily have set the popup header with the information returned by its REST service, but this way, I already have the name in the header while the page shows "Retrieving data..." That is in a label which the REST service Success event hides. And that event also unhides the grid with the contact's info, which is originally hidden.
Hope this helps someone else. And thank you, again, Maryna, for the code to get all the html from the list item. Fyi, it includes all the html on the entire list item, on both sides of the split.
Hi Fred.
Many thanks for your help to other users in the search of a common solution to their questions.
There is another solution for the same goals (I guess there could be more useful and beautiful implementation).
So the method is - to store all entity (data-item) information about list-item in the root-item element attribute "data-fullItemEntity".
To do this you need:
ol
liNavigate to the mapping./li
liRoot element mapping - "Add JS"./li
liInsert this JS code:/li
pre
//Storing current entity item data to the root element attribute "data-fullItemEntity" in json format.
jQuery(element).attr("data-fullItemEntity", JSON.stringify(value));
return value;
/pre
liOn the click event add the following code:/li
pre
var rootListItemElement = jQuery(this).closest("li");
var listItemEntityString = rootListItemElement.attr("data-fullItemEntity");
var listItemEntity = JSON.parse(listItemEntityString);
//Here you can use original list item entity through the "listItemEntity" variable.
/pre
/ol
Regards.
Thanks for the additional option. However, I believe this one line of code from Myrna, in the click event, does every thing that all of yours does (this puts it in the variable "txt" rather than "listItemEntity"
pre
var txt = $(this).closest("li").html();
/pre
hi Kateryna,
I had to retreive the Counter Value (where I am storing IDs that i get from a mapped REST service).
I dunno if this is right but I added the following to my CSS file. In the List item properties the Counter visible property is set to true
.ui-li-count {
display: none;
}
And now the counter does not appear and the following code works and I can get the Counter value of the clicked list item ![]()
var currentLi = jQuery(this).closest("li");
var counterElement = currentLi.find('.ui-li-count');
var counterText = counterElement.text().replace(/[\d]/gi, "");
alert("counterText = " + counterText);
Just in case this helps anyone.
Thanks,
M&M
Dear Murali,
Read more about CSS http://www.w3schools.com/cssref/pr_cl...
You are making it invisible by setting 'display' style of tag to 'none' value.