Drop event not firing in Blazor drag and drop - drag-and-drop

I'm having a strange problem with Blazor...
I had an application where I was using drag and drop and it was working fine using .Net Core 3.1. However the drop event is now not getting fired no matter what I do and I'm at a loss as to why. So I've created a new Blazor project and kept everything as it is in the standard project template, but I've modified the Index.razor page with the following code to see if I can find out what's going wrong:-
#page "/"
<h1>Hello, world!</h1>
Welcome to your new app.
<ul>
<li draggable="true" #ondragstart="OnDragStart" style="background-color:blue;color:white;width:50px;height:50px;">drag me</li>
</ul>
<div dropzone="move" #ondrop="OnDrop" #ondragover:preventDefault style="background-color:green;color:white;width:200px;height:200px;">
and drop me here
</div>
<div>#DragState</div>
#code {
public string DragState = "waiting...";
public void OnDragStart(DragEventArgs dragEventArgs)
{
DragState = "drag started";
}
public void OnDrop(DragEventArgs dragEventArgs)
{
DragState = "item dropped";
}
}
As far as I can see this should work, the drag start event works fine but any browser (FireFox, Chrome etc...) I try the drop event never gets fired.
I'm guessing I must be doing something glaringly wrong somewhere but I cannot see it, so I'm hoping someone else can :-)
Note, I've not changed any other file or setting in the default Blazor project, just this modification to the Index.razor file to test the drag and drop...

You have code to preventDefault for ondragover event but the syntax is wrong. Change your dropzone to
<div dropzone="move" #ondrop="OnDrop" ondragover="event.preventDefault();" style="background-color:green;color:white;width:200px;height:200px;">
and drop me here
</div>
and it should work fine.

Related

JqModal AjaxText not appearing

I have a delegated popup that is designed to display a modal on tablets and phones. Unfortunately, the modal appears to wait until the ajax call to #href is complete before it displays anything. From the docs it appears the modal should pop up with ajaxText filled in during the ajax call, but I see nothing until the popup suddenly appears. The call is predictably long enough (~5sec in development) that I know there isn't a chance that the loader isn't appearing for a split-second.
$('a.word').on(touchstart: touchWordPopup)
The following is in CoffeeScript, but follows convention from the official docs.
touchWordPopup: (event) ->
event.preventDefault()
// another function handles mouse hover popups,
// so let's disable that stuff.
$(this).off('mouseover mouseenter mouseleave')
$('#popup').jqm(
closeClass: 'close'
ajax: #href
ajaxText: '<h2>Loading...</h2>'
modal: true
).jqmShow()
HTML:
<html>
<head>...</head>
<body>
<div class='subscription'>
<a href="/words/foo" class='word'>Foo</a>
<!-- several more words... -->
</div>
<div id='popup' class='jqmWindow'></div>
</body>
</html>
I'm wondering whether delegation or CoffeeScript could be to blame, but I can't tell where the problem might be fixed.
The CoffeeScript is not to blame.
I've released jqModal 1.3.0, which immediately shows (displays) ajax enabled modals.
Documentation has been updated, and I've included an example (#5) to test for slower remote responses.
Because the equivalent of jqmShow() is now triggered immediately, if your ajax response includes elements that match closeClass, they will never attach. This is best corrected by patching jqModal and binding the event handler to the modal iteself, but for now you can use onLoad:
onLoad: function(hash){
var modal = hash.w;
$(hash.o.closeClass, modal).click(function(){
modal.jqmClose();
return false;
});
}

GWT anchor to kick off new css class

Im building a nav menu and am struggling with something really simple here. In my UI binder i have this
<header class="{res.css.mainHeader}">
<a href="#{res.css.mainNav}" class="{res.css.openMenu}">
open
</a>
<a href="#" class="{res.css.closeMenu}">
close
</a>
<h1>new header</h1>
</header>
So when I write and test this in html, it works fine. you click on the word open, and everything animates, shows all the cool stuff, the world is a happy place. But i can't figure out how to translate this into GWT.
When I run the above code, I get this error
[WARN] [itrgwtprototype] - Escaping unsafe runtime String expression used for URI with UriUtils.fromString(). Use SafeUri instead: <a class='{res.css.openMenu}' href='#{res.css.mainNav}'> (:20)
But I have a sneaking suspicion that GWT has a better way to do it than SafeUri. How do i make this work? The CSS stuff is correct, but the anchor click is whats messed up.
thanks.
You are setting the anchor href property with a css value (href="#{res.css.mainNav}").
If you want to translate it entirely in GWT you should listen to ClickEvent on you open menu and then do something like open a panel or something else. In order to do so you can replace the anchor with a Label (or InlineLabel) and listen on click events on it.

SyncFusion : syncfusion dialog does not open correctly in Internet Explorer

I am using SyncFusion dialog box as below in one of my project.
<%=Html.Syncfusion().Dialog("divUpdateStatus")
.Title("Update Status")
.AutoOpen(false).Modal(true).Width(550).Height(370)
.AutoFormat(Skins.Office2007Black)
.Resizable(false)
%>
It does work fine in all the browsers except Internet Exploere(any version).
When I click on the button to open this dialog, it does open but everything is inactive.
All the buttons and textboxes on the dialog are disabled.
Not even Cross button to cancel the dialog is enabled to close the dialog.
I have to press 'ESC' to comeout of this, then again I click on button to open that, it works fine.
On the added reference of the Syncfusion dll, it shows Version: 10.204.0.56
Anyone has idea on this?
Thank you,
I have used Syncfusion Dialog in my application, but it is working fine in Internet Explorer for me. My application referred jquery-1.4.2 script and jquery-ui-1.8.22 script within it. Dialog is working fine with this.
I have used Syncfusion version 10.2.0.56 and use the below code to render Dialog,
<code>
<div id="divUpdateStatus" style="visibility: hidden;">
<%=Html.Label("lbl", "UserName") %>
<%=Html.TextBox("text")%><br /><br />
<%=Html.Label("lbl2", "Password")%>
<%=Html.TextBox("text")%><br /><br />
<%=Html.Syncfusion().Button("btn").Text("Submit")%>
</div>
<%=Html.Syncfusion().Dialog("divUpdateStatus").Title("UpdateStatus").AutoOpen(false).Modal(true).Width(550).Height(370).AutoFormat(Skins.Office2007Black).Resizable(false) %>
<%=Html.Syncfusion().Button("button").ClientSideOnClick("onclick").Text("Click to open the dialog")%>
<script type="text/javascript">
function onclick(sender, args) {
$("#divUpdateStatus").dialog("open");
}
</script>
</code>
Share more details or issue reproducible steps in detail and we will see what’s wrong with your code.
Regards,

jqtouch go back after form submiting

I'm using jQtouch to build a page where the user can enter a kind of an ID and
get information (exam result) for this ID.
Because I take the results from the server, I used a form in the first page
with a text field and a submit button, and the action of this form send the user to the next page. Or at least, supposed to...
The problem is that also I'm being transferred to page with the results, and see the results properly, the Back button do nothing! BTW, in the address bar (above) I still see the name of the first page.
How can I go back to the "form" page? Thanks
<div class="current" id="byUserId">
<div class="toolbar">
<a class="back" id="goBack" > Back</a>
<h1> Exam Results</h1>
</div> ...
where the id="goBack" has a javascript:
$(function() {
$('#goBack').click(function() {
location.href = "enterId.jsp";
});
});
Using the regular back doesn;t work either:
<a class="back" href="#"> Back</a>
I now this is pretty late, but I had a similar frustrations and finally figured it out. The problem is that jQTouch intercepts all AJAX and form submit commands and safely send them itself. This isn't a problem except for when it's expecting some sort of callback, and there isn't one. In my case, I wanted to submit a form without a callback. To do this, look in the jqtouch.js library (around line 434) and comment out the following line:
if (href != '#') {
$.ajax({
url: href,
data: settings.data,
type: settings.method,
success: function (data) {
**// var firstPage = insertPages(data, settings.animation);**
This basically just tells jQTouch to submit the AJAX call but do nothing afterwards (don't change div's, don't show any callbacks and don't do any animations). Hope this helps.

jQuery-mobile does not play well with jQuery-tmpl?

Is there any reason why the same template and JavaScript
<script id="taskTemplate" type="text/x-jquery-tmpl">
<li>${name}</li>
</script>
$.getJSON(url, function(data) {
$("#taskTemplate").tmpl(data).appendTo("#tasks");
});
would work as documented with the following jqtouch markup:
<ul class="rounded" id="tasks"></ul>
but result in the template getting rendered outside (after) the unordered list with the following jquery-mobile markup?
<div data-role="content">
<ul data-role="listview" id="tasks"></ul>
</div><!-- /content -->
I realize jquery-mobile is in alpha release, but it has been working nicely so far and I'd prefer not to switch to jqtouch at this stage. Has anyone seen this behavior and found a workaround?
You need to call the refresh method of the listview once your templating is done.
$("yourUl").listview("refresh");
In case .page() method has never been called you may want to do something like this.
try {
$(yourUl).listview("refresh");
} catch(e){
// Well, nothing to do there
}
This has been fixed in alpha 2. See here: http://jquerymobile.com/demos/1.0a2/#docs/lists/docs-lists.html (scroll down to 'Updating lists')
It should look like
$("#taskTemplate").tmpl(data).appendTo("#tasks").page();
you need the .page() at the end.