Monday, November 10, 2014

bootstrap carousel control

Recently I was working on bootstrap carousel . I was looking for something like 

  • I don't want cycle on the images as well as no back action on first page and no forward button on the last page
  • And don't want  to navigate to the next until i clicked the icon to navigate, As you know bootstrap create a  vertical section for scrolling. 

I did the following to achieve my requirement  


<div id="carousel-example-generic"  class="carousel slide" data-ride="carousel" data-interval="false">  <!-- data-interval="false"-->                     
<!-- Wrapper for slides -->
<div class="carousel-inner" >
<div class="item active">
</div>
<div class="item">
</div>
    </div>
<!-- Controls -->
<!-- style="width:1%" did the trick and enforce user to click on the icon to navigate -->
<a style="width:1%;"  class="left carousel-control" href="#carousel-example-generic1" role="button" data-slide="prev">
<!-- put any custom image you want -->
<img  height="47" width="47" />
</a>   
<a style="width:1%;" class="right carousel-control" href="#carousel-example-generic1" role="button" data-slide="next">
   <!-- put any custom image you want -->
<img   height="47" width="47" />
</a>
</div>
<!-- run the below script on load of your page and it will do the hiding and showing the navigation icon on the first and last page --> 
<script>
var checkitem = function() {
        var $this;
        $this = $("#carousel-example-generic");
        if ($("#carousel-example-generic .carousel-inner .item:first").hasClass("active")) {
            $this.children(".left").hide();
            $this.children(".right").show();
        } else if ($("#carousel-example-generic .carousel-inner .item:last").hasClass("active")) {
            $this.children(".right").hide();
            $this.children(".left").show();
        } else {
            $this.children(".carousel-control").show();
        }
    };
</script>

Happy coding :)

Friday, October 31, 2014

IE issue with window.open/ hyperlink - not opening a new tab

In IE window.open open a new pop up window but in other browser it open a new tab especially in chrome, mozilla and safari.

There is a way to get a similar behaviour in all Browser by CSS3. 

a{
target-name:new;
target-new:tab;
}

or 

<a target ="_blank" style="target-new: tab;" onclick="window.open(url);" > 
   link 
</a>

The above solution will work every where _blank will for other and target for IE .


Click here to see details    

Tuesday, July 29, 2014

Rendering problem in visualforce pages

Some time we face problem that some section is not getting re-rendered even if we are re-rendering the section from some action from my experience I have learned most of the time it stop working on the below reasons

1) We are trying to render a pageBlock or pageBlockSection 
2) We have some rendered condition on the section

Solution for point 1 is put an outputPanel and re-render it

<apex:outputPanel id="panel1">
 <apex:pageBlock> ....
</apexoutputPanel>
<apex:actionFunction reRender="panel1">

Solution for point 2 is put an outputPanel and re-render it

<apex:outputPanel id="panel1">
<apex:outputPanel rendered ={condition}>
 <apex:pageBlock> ....
</apexoutputPanel>
</apexoutputPanel>
<apex:actionFunction reRender="panel1">

The reason behind it if we have a rendered condition and the condition became false there is no html outcome hence VF page fails to re-render on second attempt as there is no DOM element for that 

Wednesday, July 16, 2014

Auto Complete in Salesforce

Hi,

In past I have worked on many auto complete for picklist, mainly for look up attributes there are many JavaScript based solution which will give you the solution but there are problems with like if you want to merge two fields like Account Number and Account Name as an option it will be a hard job.

So I have modified a solution I have found on git hub this VF component is very cool and easy to use. Though  you can attach auto complete for the object from out of the box. Please find the attached URL for this 

https://help.salesforce.com/HTViewHelpDoc?id=search_enhanced_lookup_enable_autocomplete.htm&language=en_US

Form my knowledge it is applicable for custom objects as well but the link says it is limited to certain object .


But My problem was some what different I have to show other unique attribute along with the Name or any other configurable field  





It will look like above image as soon you select it will fill the target destination field which need to be hidden I have clubbed BillingCity and Name for example 

Total code can be found at 

https://drive.google.com/file/d/0B5TneolnEkocalh6ZHJrdkg2RXc/edit?usp=sharing

I hope this will help many developers like me who are struggling with type ahead :)  

Thanks,
Avijit 

Thursday, June 26, 2014

I missed it Cross-Object Owner Formulas

Summer '13 has a long awaited feature of mine - Cross-Object Owner Formulas.  As a developer, I can't count the number of times that I have written a trigger on objects for clients to populate a custom user lookup so they could use it in formula fields.  Almost every sObject has the owner field but it's polymorphic, meaning it can point to a queue or user. This presented Salesforce.com with a problem in their data model using formulas.  For instance, if Salesforce.com allowed you to reference Owner.FirstName and the owner was a queue, you would receive a runtime exception. Now there is native support for using cross-object formulas for all Owner fields.  The syntax is slightly different than normal.  For instance, the syntax to show a custom field from the User object would be Owner:User.MyCustomField__c.  You can also determine if the record is owned by a queue in a validation rule ISBLANK(Owner:User.Id). 

Tips on passing Salesforce AI Associate Certification

  🌟 Motivation to Pursue the Salesforce AI Associate Certification 🌟 The world of technology is in a state of perpetual evolution, and on...