4

What is the best option to implement visualforce page with view for desktop and mobile at the same place. Can this be handled automatically with modern javascript frameworks like backbone.js, angular.js, etc. For example there is Vf page and this page automatically calculates which view template to use(mobile or desktop), which model to use(mobile and desktop). Actually the mobile and desktop content and behaviour are the same but ui will be reorganized responsively within mobile.

3

Simple VisualForce pages render reasonably well in Salesforce1 as they are, but if this is general viewing via browser you'll probably find things aren't looking great. If I was going to do this I'd use Bootstrap - it's designed for creating responsive pages easily and wouldn't have an overhead as large as other frameworks.

| improve this answer | |
3

In the case that you are inside the Salesforce1 Mobile App, you can use the 'sforce' Javascript object to identify mobile vs desktop:

// Do something in inside the Salesforce1 Mobile App
if( (typeof sforce != 'undefined') && (sforce != null) ) {
  // Salesforce1 navigation
  sforce.one.navigateToSObject(aId);
}
else {
  // Set the window's URL to the Visualforce page for use on Desktop
  window.location.href = '{!URLFOR($Action.Account.View, account.
Id)}';

*Note: This will be present if you navigate to /one/one.app, whether that be the Salesforce1 mobile app, in your mobile browser, or a desktop/laptop browser navigated to /one/one.app

You can also use Apex to identify the user agent

 global static Boolean isMobile() {
      String device = System.currentPageReference().getParameters().get('device');
      return (device == 'mobile');
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.