when I use bootstrap popover on fullcalendar - fullcalendar

I added on fullcalendar a bootstrap popover, but each event on the calendar must be two clicks, popover appear. here is the code.
I tried to remove the body of the click does not work.
https://jsfiddle.net/pLsraez0/6/
eventRender: function (event, element) {
element.popover({
title: function () {
return "<B>" + event.subject + "</B>";
},
placement:'auto',
html:true,
trigger : 'click',
animation : 'false',
content: function () {
return "<div>" +
"计划开始时间:" + event.start.format() +
"<br />计划结束时间:" + event.end.format() +
"<br />需求提交人:" + event.chargeusername +
"<br />需求PM:" + event.pmusername +
"<br />需求类型:" + event.projecttype +
"<br />预计工作量:" + event.workload +
"<br />需求级别:" + event.projectlevel +
"<br /><input type='hidden' value='" + event.id + "' />" +
"</div>" +
"<div style='text-align: right;margin-top: 10px;'>" +
"<button type='button' onclick='designProj(event);' class='btn btn-primary btn-xs'>指派</button>" +
"<button style='margin-left: 8px;' onclick='editProj(event);' type='button' class='btn btn-default btn-xs'>编辑</button>" +
"<button style='margin-left: 8px;' onclick='delProj(event);' type='button' class='btn btn-default btn-xs'>删除</button>" +
"</div>";
},
container:'body'
}).popover('show');
$('body').on('click', function (e) {
if (!element.is(e.target) && element.has(e.target).length === 0 && $('.popover').has(e.target).length === 0)
element.popover('hide');
});
}

You should use $(element). It work fine for me.
https://jsfiddle.net/PJ1501/pLsraez0/4/

Related

how to load partial view in ajax in asp.net core

I want to load my partial view per row when i change paging by ajax.my partial is responsible for buttons for each row in table
i have an partial view like this below :
#model Guid
<td style="width: 150px">
<div class="btn-group" role="group">
<a asp-action="Edit" asp-route-id="#Model" class="btn btn-primary text-white"><i class="fas fa-edit"></i></a>
<a asp-action="Details" asp-route-id="#Model" class="btn btn-success text-white"><i class="fas fa-list-alt"></i></a>
<a asp-action="Delete" asp-route-id="#Model" class="btn btn-danger text-white"><i class="fas fa-trash-alt"></i></a>
</div>
</td>
and i use this in my table per row :
<table id="exp" class="table table-striped border">
<tr class="table-secondary">
<th>
#Html.DisplayNameFor(c => c.List.FirstOrDefault().Title)
</th>
<th></th>
<th></th>
</tr>
#foreach (var expertise in Model.List)
{
<tr>
<td>#Html.DisplayFor(c => expertise.Title)</td>
<td>
<partial name="_TableButtonPartial" model="#expertise.Id" />
</td>
</tr>
}
</table>
<div page-model="#Model.PagingInfo" page-classes-enabled="true" page-class="btn border"
page-class-normal="btn btn-light" page-class-selected="btn btn-info active"
class="btn-group float-right">
</div>
so i want to make paging ajax but i dont know how to load this patial per row in ajax
#section Scripts
{
#{ await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script type="text/javascript">
function goToPage(param) {
var url = '#Url.Content("~/")' + param;
$.ajax({
url: url,
type: 'GET',
dataType: 'text',
success: function (data) {
var results = JSON.parse(data);
var items = '';
$('#exp').empty();
$.each(results.list,
function (i, expertise) {
items+= "<tr>" +
"<td>" + expertise.title +
"</td>" +
"<td>" +
"<partial name='_TableButtonPartial' model='" +
expertise.id +
"'/>" +
"</td>" +
"</tr>";
});
$('#exp').html(items);
}
});
}
</script>
}
how to load this partial per row in ajax
You can modify your code to dynamically get html of partial view and populate your table, like below.
$.each(results.list,
function (i, expertise) {
//make request to get the html of partial view
//and generate new rows to populate table
$.get("/Home/GetPartial/" + expertise.id, function (res) {
var newrow = "<tr>" +
"<td>" + expertise.title +
"</td>" +
"<td></td>" +
res +
"</tr>";
items += newrow;
if (i == results.list.length - 1) {
$('#exp').html(items);
}
});
});
Controller action
[Route("{controller}/{action}/{id:guid}")]
public IActionResult GetPartial(Guid id)
{
return PartialView("_TableButtonPartial", id);
}

jQuery Execute Old Variable

I have this code.
function changepriceedu() {
jQuery(document).ready(function(){
jQuery("select#calc_shipping_state").change(function(e) {
e.preventDefault();
jQuery('.single-product-top.row ins').replaceWith('<ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">S/.</span>' + totalshippingcost + '</span></ins>');
jQuery('div#boton_info ins').replaceWith('<ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">S/.</span>' + totalshippingcost + '</span></ins>');
});
});
}
I put a variable in another php file like this.
echo "<script>";
echo "var totalshippingcost = $totalshippingcost;";
echo "</script>";
But when calling the variable I get an old and not new value with the ".change" function, what would be the problem?

Thymeleaf dynamic href using input value(s)

I understand that Thymeleaf templates are rendered server-side, but is there a simple way to reference input values client side to create an href dynamically?
Here is what I currently have:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>TEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Dynamic href</h1>
<p>name: <input type="text" name="name" /></p>
<p>age: <input type="text" name="age"/></p>
<p>color: <input type="text" name="color"/></p>
<a th:href="#{/userInfo(name='Americord',age='32',color='green')}">Submit</a>
</body>
</html>
Inside of my application controller I have:
#GetMapping(value = "/userInfo")
public String userInfo(#RequestParam(value = "name") String name,
#RequestParam(value = "age") String age,
#RequestParam(value = "color") String color) {
// get user related user information
return "success";
}
As you can see, right now the values for name, age & color are simply hard-coded. But I would like to reference the values from the input fields.
Maybe something like(?) :
<a th:href="#{/userInfo(name={name.value},age={age.value},color={color.value})}">
Submit
</a>
No, the only way to do this, is by using JS or jQuery. Thymeleaf once rendered, it simply can't modify anything else. Anyways, using jQuery is quite simple and you should make it work in no time. Something like the code below would do the trick.
var ageInput = $('#age');
var nameInput = $('#name');
var url = $('#dynamic-url');
ageInput.on('change', function() {
if($(this).val() !== "" && nameInput.val() !== "") {
url.attr('href', '/userinfo(age=' + $(this).val() + ', name=' + name.val() + ')');
} else if ($(this).val() !== "") {
url.attr('href', '/userinfo(age=' + $(this).val() + ')');
} else if (nameInput.val() !== "") {
url.attr('href', '/userinfo(name=' + nameInput.val() + ')');
}
});
nameInput.on('change', function() {
if($(this).val() !== "" && ageInput.val() !== "") {
url.attr('href', '/userinfo(age=' + ageInput.val() + ', name=' + $(this).val() + ')');
} else if ($(this).val() !== "") {
url.attr('href', '/userinfo(name=' + $(this).val() + ')');
} else if (ageInput.val() !== "") {
url.attr('href', '/userinfo(age=' + ageInput.val() + ')');
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="age" type="text" placeholder="age"/>
<input id="name" type="text" placeholder="name"/>
<a id="dynamic-url" href="/userinfo">
Submit
</a>
Hope it helps!

Semantic UI Search selection dropdown is not working in safari

I work with semantic UI and loading the dropdown options dynamically. I am loading the first dropdown on page load. while selecting the options in the first dropdown, the second dropdown will be loaded.
For example : If we select country the corresponding states will be loaded in second dropdown.
But this is not working in safari.Its working in chrome.Can anyone help me?
This is my code:
$("#selectdd1").change(function () {
$.ajax({
url: apiUrl,
dataType: 'json',
data: this.value,
type: 'GET',
success: function (ResultSet) {
$('.selectdd2').find('.menu').html("");
$('#selectdd2').empty();
var $menu = $('.selectdd2').find('.menu');
$('#selectdd2').append('<option value="">Select a Company</option>');
for (var CMPIndex = 0; CMPIndex < ResultSet.length; CMPIndex++) {
var tempValue = $.trim(ResultSet[CMPIndex].Value);
$('#selectdd2').append('<option value="' + tempValue + '" keycode="' + ResultSet[CMPIndex].Key + '">' + tempValue + '</option>');
$menu.append('<div class="item" data-value="' + tempValue + '">' + tempValue + '</div>');
};
$('#selectCompany').dropdown({
placeholder: "Select",
});
}
});
});
HTML Page
<div class="form-group selectDD1">
<select class="ui search selection dropdown dropdown-spinner
centwidth" id="dd1" name="dd1">
<option value="">Select a Broker</option>
</select>
</div>
<div class="form-group selectDD2">
<select class="ui search selection dropdown dropdown-spinner
centwidth" id="selectdd2" name="select">
<option value="">Select a Broker</option>
</select>
</div>

Kendo UI MVC Client Template with Conditions not working

columns.Bound(p => p.isCurrentlyLocked)
.ClientTemplate("# if (isCurrentlyLocked && roles != 'Admin') { #"
+ "<input type='button' onclick='user_unlock' value='Unlock' class='k-button' />"
+ "# } else if(!isCurrentlyLocked && roles != 'Admin') {#"
+ "<input type='button' onclick='user_lock' value='Lock' class='k-button' />"
+ "#}#");
columns.Template(p => p.roles).ClientTemplate("# if (roles != 'Admin') { #"
+ "<input type='button' onclick='user_delete' value='Delete' class='k-button' />"
+ "# }#");
I can't call my Javascript Functions user_unlock, user_lock or user_delete. The Server generates Html like onclick=\u0027user_delete\u0027. Does anyone know how to fix this ?
Can you try as follow:-
columns.Template(p => p.roles).ClientTemplate("# if (roles != \"Admin\") { #"
+ "<input type=\"button\" onclick=\"user_delete()\" value=\"Delete\" class=\"k-button\" />"
+ "# }#");

Resources