Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7002125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:53:21+00:00 2026-05-27T20:53:21+00:00

Unobtrusive JavaScript with jQuery is available in MVC3.But how can I use the unobtrusive

  • 0

Unobtrusive JavaScript with jQuery is available in MVC3.But how can I use the unobtrusive Javascript ajax with mootools?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:53:21+00:00Added an answer on May 27, 2026 at 8:53 pm

    yeah, this is trivial to do. have a look at the recently released http://mootools.net/blog/2011/12/20/mootools-behavior/, I think it supports it.

    I have used this approach in my Modal.BootStrap (view source on github, link’s there) as well whereby it uses data attributes to fetch data from an ajax resource, it’s not quite the same but it certainly is a start.

    I just spent 10 mins making this and it’s a good start:

    http://jsfiddle.net/dimitar/zYLtQ/

    (function() {
    
        var ajaxify = this.ajaxify = new Class({
    
            Implements: [Options,Events],
    
            options: {
                mask: "form[data-ajax=true]",
                props: {
                    ajaxLoading: "data-ajax-loading",
                    ajaxMode: "data-ajax-mode",
                    ajaxUpdate: "data-ajax-update",
                    ajaxSuccessEvent: "data-event-success"
                }  
            },
    
            initialize: function(options) {
                this.setOptions(options);
                this.elements = document.getElements(this.options.mask);
                this.attachEvents();
            },
    
            attachEvents: function() {
                this.elements.each(function(form) {
                    var props = {};
                    Object.each(this.options.props, function(value, key) {
                        props[key] = form.get(value) || "";
                    });
    
                    form.store("props", props);
                    form.addEvent("submit", this.handleSubmit.bind(this));
                }, this);
    
            },
    
            handleSubmit: function(e) {
                e && e.stop && e.stop();
                var form = e.target, props = form.retrieve("props"), self = this;
                var updateTarget = document.getElement(props.ajaxUpdate);
    
                new Request({
                    url: form.get("action"),
                    data: form,
                    onRequest: function() {
                        if (props.ajaxLoading) {
                            var loading = document.getElement(props.ajaxLoading);
                            if (loading && updateTarget) {
                                updateTarget.set("html", loading.get("html"));
                            }
    
                        }
                    },
                    onSuccess: function() {                             
                        if (!updateTarget)
                           return;
    
                        if(props.ajaxMode != 'append') {
                            updateTarget.set("html", this.response.text);
                        }
                        else {
                            updateTarget.adopt(new Element("div", { html: this.response.text }));
                        }     
    
                        if (props.ajaxSuccessEvent)
                            self.fireEvent(props.ajaxSuccessEvent, this.response);       
                    }
    
                }).send();
    
            }
    
        });
    
    })();
    
    
    new ajaxify({
        onContactFormSuccess: function(responseObj) {
            console.log(responseObj.text);
            alert("we are done.");
        }
    });
    

    works with a DOM of:

    <form action="/echo/html/" data-ajax="true"  data-ajax-loading="#loading" data-ajax-mode="replace" data-ajax-update="#update" data-event-success="contactFormSuccess" method="post">
        <input name="delay" value="4" type="hidden" />
        <input name="html" value="Thanks for your submission, this is the jsfiddle testing response" type="hidden" />
        <input name="name" placeholder="your name" />
        <button>submit</button>
    </form>
    
    <div id="update">The update will go here.</div>  
    <div id="loading">loading...</div>        
    

    you should be able to build on that. on refactor i’d move the request events into their own methods and add some more proofing etc but it’s fine. i don’t know all mvc does but one thing that is missing is form validation events. i also added a custom event that is fired when done so your ajaxifier instance can do something particular to that form (see data-event-success="contactFormSuccess")

    also, it can use default request options if not implicitly specified, even what request object to create – Request, Request.HTML, Request.JSON etc. Events like onRequest, spinners etc are also feasible… I think you just need to work your way through the options that mvc provides and build them to get started.

    Confirm     data-ajax-confirm
    HttpMethod  data-ajax-method
    InsertionMode   data-ajax-mode *
    LoadingElementDuration  data-ajax-loading-duration **
    LoadingElementId    data-ajax-loading
    OnBegin     data-ajax-begin
    OnComplete  data-ajax-complete
    OnFailure   data-ajax-failure
    OnSuccess   data-ajax-success
    UpdateTargetId  data-ajax-update
    Url     data-ajax-url
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can we use unobtrusive javascript to implement features like autocomplete in jquery? or should
How can I use the Prototype library and create unobtrusive javascript to inject the
I'm looking for a good 10 minute introduction to Unobtrusive Javascript using JQuery. I'm
I'm using rails, but doing all my Javascript unobtrusively using jQuery in application.js .
I'm reworking an old website and am focusing on making the Javascript/jQuery as unobtrusive
I'm writing an MVC3 site, and I'm using JQuery unobtrusive validation to validate my
I wrote a custom validator using MVC DataAnnotations and the jQuery unobtrusive javascript library.
I have an extremely simple example trying to use Data Annotations with unobtrusive javascript
I’m using a CDN for the following javascript: https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js http://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js For each
I am converting a standard scaffold generated application to use AJAX and JQuery in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.