Create tooltip by code

Hi,
    i need to create a tooltip from code javascript in razor page, like:

var tooltipObj = new Tooltip({ content: 'Tooltip text' });
tooltipObj.appendTo("#cmbCustomer");

But it gives error "Tooltip is not defined". How do I import the module, I think "Popups", correctly?

Best regards,
Massimo


3 Replies

KR Keerthana Rajendran Syncfusion Team March 2, 2022 01:07 PM UTC

Hi Massimo,  
 
Greetings from Syncfusion support. 
 
You can create a Toolitp from JavaScript in razor page using the below code snippet. 
 
[Home/index.cshtml], 
 
@{ 
    ViewData["Title"] = "Home Page"; 
} 
 
<div id='container'> 
    <div style="margin: 50px;"> 
        <span id='target'>Show Tooltip</span> 
    </div> 
</div> 
<script> 
    //Initialize Essential JS 2 JavaScript Tooltip component 
    var tooltip = new ej.popups.Tooltip({ 
        width: '150px', 
        height: '40px', 
        content: 'Tooltip text' 
    }); 
    tooltip.appendTo('#target'); 
</script> 
 
 
Also, refer to the below documentation to know more about Tooltip component in JavaScript. 
 
 
Please check the attached sample and get back to us if you need any further assistance. 
 
Regards, 
Keerthana R. 
 



MA Massimo March 7, 2022 12:51 PM UTC

Ok, that's what I needed, thank you

Regards,
Massimo



KR Keerthana Rajendran Syncfusion Team March 8, 2022 05:36 AM UTC

Hi Massimo, 

We are glad that the provided suggestions helped you. Please let us know if you need any further assistance. 

Regards, 
Keerthana R. 


Loader.
Up arrow icon