valueHelpRequest method not get fired in sap.m.input by enabling showValueHelp="true" - sapui5

I want to show password by clicking help indicator in control sap.m.input.
As per code valueHelpRequest method must fired but not fired when clicking help indicator.

Its working fine for me. Share some code.
jsbin sample
js view code
createContent: function(oController) {
// button text is bound to Model, "press" action is bound to Controller's event handler
return new sap.m.Input({text:'{/actionName}',press:oController.doSomething,showSuggestion:true,showValueHelp:true,valueHelpRequest:oController.onVHR});
}

I got solution :
var oInput = this.getView().byId("idName"); oInput.attachValueHelpRequest(function(){
console.log("You click on value helper.")
});

Related

SAP UI5 - onscrollstart and onscrollstop event handling

I am trying to capture scroll start/stop events for a page control. I want to find out if the last field of the page is in the viewport. The way I am trying to figure out if field is in the viewport is by using the method getBoundingClientRect(). All this works fine but I am not able to invoke this method as I am not able to capture the scroll event. I intend to call this method inside the event handler for scrollstop, so I know the user has stopped the scroll and now is the time to check if the field is reached.
Using this link to find out the events that can be handled:
https://sapui5.hana.ondemand.com/#/api/module:sap/ui/events/ControlEvents
It is a touch device so need to figure out how to handle touch event as well.
Currently, below is the code for mouse scroll which is not working. Other events like clicked, mouseover are working.
How to get onscrollstart and onscrollstop to work?
In controller.js
onAfterRendering: function () {
controller.getView().byId("PAGECONTROLID").addEventDelegate({
onclick: function(){
console.log("clicked"); // works on all panels within the page
},
onmouseover: function(){
console.log("mouseover"); // works on all panels within the page
},
onscroll: function(){
console.log("onscroll"); // IS NOT CORRECT EVENT, but tried it anyway
},
onscrollstart: function(){
console.log("scroll start"); // DOES NOT WORK
},
onscrollstop: function(){
console.log("scroll stop"); // DOES NOT WORK
}
})

SAPUi5 dropdownbox select event

We have used dropdownbox.
var r1c1 = new sap.ui.commons.DropdownBox("r1c1");
r1c1.addEventDelegate({
onselect : function(oEvent) {
}
});
The breakpoint is not stopping at this, it was working fine, We have put logic based on onselect event. Is someone facing the same issue,
Even in browser, i have put Event listener select event, it is not getting stopped for that also.
Best regards,
Rohit
var r1c1 = new sap.ui.commons.DropdownBox({
change: yourFunction
})

Issue with document.ready function in jQuery

I am having one issue with document.ready jQuery function.
On load the document.ready function is working fine. When I click on the button or href link, I want to reconnect with the document.ready function where I have set of code in JavaScript file.
Here is the actual scenario. Please find below sample JS code:
$(document).ready(function() {
var title = "This is your title";
var shortText = jQuery.trim(title).substring(0, 10).split(" ").slice(0, -1).join(" ") + "...";
alert(shortText );
});
After clicking submit button i am adding the input fields data in the below table row. In which description texts are also added in one of table row columns. If description field has more than 100 character, I am pushing the above mentioned JavaScript code from external .JS file. How can i refresh the Java script function without refreshing the page? Anyone have idea?
Please share your opinion.
Create a function, that you can call both in document.ready, and also anywhere else, such as a buttons click event:
function myfunc(){
var title = "This is your title";
var shortText = jQuery.trim(title).substring(0, 10).split(" ").slice(0, -1).join(" ") + "...";
alert(shortText );
}
$(document).ready(function() {
//call when document is ready
myfunc();
//call again when button is clicked
$('#button').click(myfunc());
});

Fire click event on button by code?

Simple enough just can't get it to work and see no info within the docs. How to fire click event on button by code?
I have tried:
btn.fireEvent('click');
The button already has an event listener, I want it to run the code within the listener when the app is in a certain state.
you have to add EventListner to check whether click event is fired or not,see below code ,it fires without clicking the button. you can replace commented if condition with your condition on which you want to fire btn's click event
var win= Titanium.UI.createWindow({ backgroundColor:'white'});
win.open();
var btn= Titanium.UI.createButton({ title :' fire by code'});
btn.addEventListener('click',function(){
alert('Click event fired ');
});
win.add(btn);
//if(appState)
btn.fireEvent('click');
I would probably approach this a different way. You want an application to do the same thing if the button is clicked or if the app is already in a certain state.
function doThisThing(){
alert('This thing happened');
}
var win = Titanium.UI.createWindow({ backgroundColor:'white'});
win.open();
var btn = Titanium.UI.createButton({ title :' fire by code'});
btn.addEventListener('click',function(){
doThisThing();
});
// could also be defined as btn.addEventListener('click', doThisThing());
win.add(btn);
//if(appState)
doThisThing();
+1 to adnan for providing the code example to change around.

How to identify the ID or value of when the submit button is clicked

I am having trouble identifying the particular value or ID of a submit button after it has been clicked and submitted using AJAX.
If I place the following code as a global function, it properly alerts the value of the button clicked:
$(":submit").live('click', function() {
alert($(this).val());
})
However, when I attempt to define the variable, I am unable to use that variable from within the success callback function:
$(":submit").live('click', function() {
var whichButton = $(this).val();
})
...
$("#applicant-form").validate({
function(form) {
$(form).ajaxSubmit({
...
success: alert(whichButton);
I have also tried placing the code in the submitHandler, but that doesn't work either.
In a somewhat related post, a user had suggested I place the following code:
$("#accordion .edit").click(function(){
window.lastButtonClicked = this;
});
...
submitHandler: function(){
var index_origin = $(window.lastButtonClicked).attr("name");
}
But I was not able to get that to get the value of the button clicked (it said that the value was undefined).
Any suggestions?
UPDATE: It might help if I provide more information about why I need to know which button is pressed. I have two kinds of submit buttons for each form in a multi-part form. I would like to do different things based on which button was clicked.
$(":submit").live('click', function() {
var whichButton = $(this).val();
})
The scope of whichbutton is inside of this anonymous function; you can't access it from elsewhere. A quick fix might be to declare whichbutton as a global variable but there's probably very few cases where you should do that. More context as to what it is you're trying to do would help, right now it just looks like you're trying to alert the button text on success after an ajax form submit.