My question is very simple.
In ADF Mobile, I have HTML page and there is a button on it. I want to run JavaScript code on button click and navigate to AMX Page. How I can achieve this functionality.
Thank You!
In button properties in AMX page click action listener and create Bean and Method
Add below code in order to execute zoomIn JS Function
AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.mohamed.ios.feature1",
"zoomIn",
new Object[] { });
First Parameter: Feature Id
Second Parameter: Javascript Function
Name Third Parameter: Java Script Function Parameters
If it's HTML page once you choose a button in property inspector under javascript you will find all the javascript events you can use( if property inspector not visible click View -> Property Inspector).
you can add the JS function in the OnClick event then in that JS function you can use below code to go to the feature that has your AMX page.
adf.mf.api.gotoFeature("feature0",
function(req, res) { alert("gotoFeature complete"); },
function(req, res) { alert("gotoFeature failed with " +
adf.mf.util.stringify(res); }
);
Make sure you include the JS file in feature under content tab.
And in order to navigate to AMX page from a button on another AMX page pass the flowCase to below method
public void doNavigation(String flowCase) {
AdfmfContainerUtilities.invokeContainerJavaScriptFunction(AdfmfJavaUtilities.getFeatureName(),
"adf.mf.api.amx.doNavigation",
new Object[] { flowCase });
}
The doNavigation method is calling a standard ADFM JS API called adf.mf.api.amx.doNavigation and it passes the flowCase name to it.
Related
I have a use case where I need to navigate from one salesforce tab to other. I want the tab to which I navigate to reload as I want it to render and per new data which I will be setting in the previous tab.
I have tried using following code but it does not seem to reload the page. It just navigates to the tab.
this[NavigationMixin.Navigate]({
type: 'standard__navItemPage',
attributes: {
apiName: 'tab_api_name'
},
});
If not complete reload, is there any method which we can invoke on switching/navigating between salesforce tabs as it did not call any of the lifecycle methods while switching tabs.
You can try window.open(url, "_self");
I added this example to my sonata admin page.
I try to get the live event on select2 change status, but I can't get the event: no js error, nothing in the console.
How do I get the event on select2 in a sonata-admin edit page?
EDIT: the page contains multiple select2 html tags. I am trying to get events for all of them. I edit a collections M2M.
simply use livequery plugins
$('.myClass').livequery(function() {
$(this).on("change", function() {
alert($(this).val());
})
});
I am using angularjs for my app. It contains a newsfeed. If user needs to view the particular news, he has to click on that particular news and it will redirect to that news. And after viewing the particular news, if user wants to go back to news feed(previous page), he has to click on the browser back button. So, in this case, if user clicks on the browser back button, the newsfeed page is reloading again. But, I dont want like this. I want to disable the reload and take the user to the place where he was before. I browsed a lot on this issue, but there was no absolute solution given. Please, help me out.
When you go back, previous route will be triggered and data will be reloaded. If you want to prevent reloading, place a service in between and cache the data.
$routeProvider.
when('/loadFeeds',{
controller:'LoadFeedCtrl',
templateUrl:'pages/feeds.html',
resolve:{
initData : function(FeedService){
return $q.all(
{
data: FeedService.load()
}
);
}
}
})
And in your FeedService, instead of making http call try to see the data is already available
.service('FeedService',function($q,$timeoute){
this.feeds=[];
this.load = function(){
var deferred = $q.defer();
$timeout(function(){
if(feeds.length===0){
this.feeds.push({title:'First','id':1})
this.feeds.push({title:'Second','id':2})
this.feeds.push({title:'Third','id':3})
this.feeds.push({title:'Fourth','id':4})
}
deferred.resolve(this.feeds);
},2000);
return deferred.promise;
};
})
The timeout service could be replaced with $http or $resource. I used the timeout to simulate the delay
you can take an anchor link and on click event of anchor call this
javascript function
window.window.history.back();
here is the html code for it
<input type="button" id="alnkBack" onclick="window.window.history.back();" value="Back" class="button" />
I need to open a backbone template in a new window. Is this possible? Currently I've got a template that is being displayed within a div but I need this content to display in a new window? I thought using a route might be the way to go but I'm not sure.
I'm a noob to backbone so there's probably a better way to do this.
In my view I've got:
events:
{
'click #active-bets' : 'loadActiveBetsPage',
}
loadActiveBetsPage: function(e)
{
var MyApp = new Backbone.Router();
MyApp.navigate('activebets', {trigger: true});
// , {trigger: true, target: "_blank"}
},
I thought I might get lucky and be able to pass a target: "_blank" parameter here.
in my routes sections:
var AppRouter = Backbone.Router.extend({
routes: {
":activebets" : "renderActiveBets",
"*actions" : "defaultRoute"
} });
app_router.on('route:renderActiveBets', function () {
$this.activeBetsView = new ActiveBetsView( { el: $this.elAccountInfo });
$this.activeBetsView.render();
/* thought something like this might help possibly
if ($(event.currentTarget).prop('target') === '_blank') {
return true;
}
*/
});`
Thank you in advance for any help on this one.
No, this is not possible and especially not with the Backbone Router directly.
The only ways to open new browser windows from a webpage are using the window.open javascript method. It will open a new browser window that directs to the URL specified. Note that the the page you have created and the page you started at are independent of each other and there is no way to communicate between them via javascript.
The other way is to have an anchor tag with the target -attribute, which results in clicking the link opening a new window/tab.
What you can do:
Use a dialog created with html to simulate a new window, e.g. jQuery UI Dialog
Create a separate webpage to display this information, open a new browser window and direct the new window to this webpage.
Update based on last comment:
"...there is no way to communicate between them via javascript."
Since HTML5, the solution for this is HTML5 Web Storage.
window.localStorage
is API that can communicate with all open tabs and windows in browser.
After rendering a Backbone View I inject HTML generated with jQuery. This HTML also includes links within the application. If you click those links they reload the site.
How can I bind those links so they will trigger the router and don't reload the site?
You have to bind a click event to those links and call Router.navigate. It's important that you return false from your event handler as this will prevent the borwser to actually follow the link. Another important thing is to pass trigger: true to actually have your router execute (otherwise it will only change the url displayed in the address bar).
events : {
'click a.changeView' : 'changeView'
},
changeView : function(e) {
Router.navigate(e.target.href, { trigger: true });
return false;
}
Also, you might have to tweak your href a bit if it contains protocol, domain, etc... for instance if your href is http://mydomain.com/mypage you might need to pass only mypage to the router.