I'm novice with jQuery dialog and I'm looking for a way to replace to ugly confirm javascript function by a jQuery dialog. If possible I would like a solution as easy as possible to set in place.
Example:
if (confirm("Are you sure?")) {
// user click Yes
}
To be replaced by a simple jQuery dialog solution. If possible an 'inline' solution like:
if jQconfirm("Are you sure") { ... }
I don't know if some solutions already exist?
Thanks.
It is complicated to have such an inline solution since the confirm() halts the execution of the script, however you may modify you script a bit and use such a construct:
$.confirm("message", "title",
function() { /* Ok action here*/
});
Check this site for the solution.
try this
http://jqueryui.com/demos/dialog/#modal-confirmation
its the JqueryUI box, and works well in a model form
Related
first of all I try to use proper "language" but I am not a programmer. That said...
I don't seem to be able to get jquery mobile to work properly.
When I try to change document.ready(function() { ... })
to
document.on('pagecreate', function(){ ... })
I do not get the same result; in fact I cannot even alert a simple message.
Furthermore I would like to use mousedown and mousedown events. The documentation of jquery mobile tells me that I could use vmousedown and vmouseup. Does not work either. Can someone enlighten me please. the jquery mobile.js is added lastly in my script structure of the dom.
Maybe relevant for others with a similar problem.
Linking to the jquery CDN instead of hosting the files myself solved my problem.
I just tried it and it doesn't work.
jQuery Mobile seems to get rid of the ?golfer=arnoldpalmer part of the link (you can see this via view source).
Any workarounds or solutions?
Is this because the standards are that we cannot put parameters behind page hash links?
As #zyrex pointed out, there are "pure" jQuery mobile solution.
Another popular solution is to rely on Backbone Routers which provide out of the box parsing of parameters in URLs.
Should you use this, you must deactivate hashtag interception in JQuery Mobile using
$( document ).on( "mobileinit",
// Set up the "mobileinit" handler before requiring jQuery Mobile's module
function() {
// Prevents all anchor click handling including the addition of active button state and alternate link bluring.
$.mobile.linkBindingEnabled = false;
// Disabling this will prevent jQuery Mobile from handling hash changes
$.mobile.hashListeningEnabled = false;
}
)
Create Routes in the Router
routes: {
"": "start",
"page2/:golfer": "gotopage2"
}
And do JQM navigation in your handler
gotopage2: function( golfer ) {
//do something with golfer
//show JQM page
$.mobile.pageContainer.pagecontainer( "change", "#page2")
}
this should solve your problem :) there are three ways to pass parameters.
Value Passing In Jquery from one html class to other html class in PhoneGap
I have an application which includes a series of forms, each on their own page.
I do not want some of these pages to be added to the history stack. So that when the user presses back, it skips them.
Jquery-mobile does this with dialogs. You can configure this to happen with ALL pages (or any other data-role) but not with just some pages.
Does anyone know how to do this? Alternatively, would it be possible to create a new data-role that extends "page". If that was possible, then I could disable history for all of those pages.
in this case, you can call $.mobile.changePage() by yourself:
$.mobile.changePage( "url", {
changeHash: false //do not track it in history
});
http://jquerymobile.com/demos/1.2.0/docs/pages/page-navmodel.html
http://jquerymobile.com/demos/1.2.0/docs/api/methods.html
I was facing the same issue and I was going berserk!!! Finally, I was able to do it with the following code that does just that!
The code below automatically prevents storing the changed locations for all pages in the current document.
Please note that it has been tested with jqm 1.4.2
<script>
$(document).on("pagebeforetransition",function(event, ui){
ui.options.changeHash = false;
}) ;
</script>
Hope it helps
Checkout this question, pretty much the same as what you are trying to do.
How to modify jQuery mobile history Back Button behavior
Thanks,
Alex.
I think about the solution of situation, when after typing a few letters you will get a words from database and after click on a loaded word will be send the form?
In the basic shape about autocomplete, so after click on a loaded word will this word set to input.
Thank you
The question is not very clear - but I'm guessing that after autocomplete you want to automatically submit the form. You can do this by calling submit in the select callback
I don't know what implementation of autocomplete you are using but if you are using the jQuery-UI autocomplete widget there is a callback you can put right in the autocomplete configuration hash:
$( ".selector" ).autocomplete({
select: function(event, ui) { ... }
});
If you aren't using this widget then my answer isn't as terribly useful of course and I apologize. There isn't a lot of detail in your question.
On a side note, if you're using a home grown autocomplete implementation I'd strongly suggest you investigate the jQuery-UI option
What I want to do is to call a JavaScript routine when the user clicks on a radiobutton. I've some fields to enable/disable when this happens. However, when I enter
<%=Html.RadioButton("obp17", "57", ViewData.Eval("obpValue17").ToString().Equals("57"), new {#onclick = "Yes()"})%>
I'm getting a "type or with" expected error when trying to add the onlick event. This should be easy, but none of samples I've found seem to work. The leading "#" is common in all the examples I've found, but something else seems to be missing.
And yes I know the way of checking for "true" is overkill, but it is created with a special purpose code generator, so it wasn't any extra work.
Any thoughts?
Pardon me for causing anyone problems. My problem was ultimately caused by delete the first line of the ASCX file that inherits "System.Web.Mvc.ViewUserControl" Once I put that in, all the problems went away.
The line of code that worked was
<%= Html.TextBox("obpt9",ViewData.Eval("obpt9"), new { onclick = "alert('hi')" })%>
Different line than sample, but they are all the same.
Again, sorry for causing anyone confusion.
tom
Is the page language VB or C#? If it's VB your syntax is wrong for creating the anonymous typed html attributes. See this MSDN reference on how to create an object with an anonymous type in VB.
<%=Html.RadioButton("obp17",
"57",
ViewData.Eval("obpValue17").ToString().Equals("57"),
New With { .onclick = "Yes()" } ) %>
Or change the page language to C#, if that's more appropriate.
Also, note that you could (arguably should) simply give the radio button a class, then add all the handlers at one time with jQuery. Usually you want to keep your javascript separate from your mark up.
<%=Html.RadioButton("obp17",
"57",
ViewData.Eval("obpValue17").ToString().Equals("57"),
New With { .class = "heinz" } ) %>
<script type="text/javascript>
$('.heinz').click( function() {
... implement the logic of Yes() here ...
});
</script>
The general structure Looks like the following:
#Html.RadioButtonFor(t => t.ViewModelVariableName,"RadioButtonValue", new {javascriptEvent = "javascriptMethodName"});
Do you have Yes() function correctly defined in your code ? Replace Yes() to the javascript alert() function ; if that works, then the line of code you posted is OK.
Also, please post Yes() function here, and I think there may be some error there.