13

has a method like the replacement of mootools in jquery

 2 years ago
source link: https://www.codesd.com/item/has-a-method-like-the-replacement-of-mootools-in-jquery.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

has a method like the replacement of mootools in jquery

advertisements

this is mootools code:

var myString = "{subject} is {property_1} and {property_2}.";
var myObject = {subject: 'Jack Bauer', property_1: 'our lord', property_2: 'savior'};
myString.substitute(myObject);

and does jquery has this mothod? or like this method ?


No, but there's nothing preventing you from adding it yourself:

jQuery.substitute = function(str, sub) {
    return str.replace(/\{(.+?)\}/g, function($0, $1) {
        return $1 in sub ? sub[$1] : $0;
    });
};

// usage:
jQuery.substitute('{foo}', {foo:'123'});

Related Articles

C # calling method before the replacement method

Good day, I have a base class with a virtual method that needs to be overridden per implementation, but I would like to call the base method first before overriding. Is there a way to accomplish this without having to actually call the method. public

Java / JSF / Tomcat / Spring - Proxy-Object has different methods than the original object

today I ran into this problem which really bugs me, as almost the code already worked (and stopped working even after reverting to the older version). I'm accessing a Spring-Bean on a Facelets-Page. Spring wraps these objects in Proxies to use aspect

How can I call a base class method from the derived class, if the derived class has a method with the same name?

this is what I want to be able to do: (pseudo code) class DerivedClass : public BaseClass { public Draw() { BaseClass.Draw() } } class BaseClass { protected Draw(); } Both draws have the same name and the same signature. The reason for wanting to do

Displaying the simple method of the MVC action controller with jquery

I'm just trying to pass a simple object to an MVC controller method without having to create a view model for it. The parameter in the controller method is always null though it id getting called. My jquery post is below. $(function () { $("button[id

What is the best way to call a php method in the zend template using javascript / jQuery

I'm developing a website where i have to communicate with web services. I'm using Ajax calls like this, for instance if I want to call a method called getCustomer(...) I have in my Zend project a module called "customer". Inside of my controller

In javascript, how to create more than one clone with less code like the clone () method in jQuery

clone() method in jQuery: var imgElement = $('<img src="img.png"/>').clone(); $(imgElement).appendTo('#ulSelector1 li'); $(imgElement).appendTo('#ulSelector2 li'); $(imgElement).appendTo('#ulSelector3 li'); so i tried the cloneNode() metho

Customized craft commands with several "methods" (in the migration style: install, etc.)

I'm creating a custom artisan command (foo) for my Laravel 4 application. I can see from the userguide how to accept arguments and options, e.g. php artisan foo argument --option But what if I want to have a custom artisan command that has many 'meth

What should be the 'pop ()' method when the stack is empty?

Possible Duplicate: C++ STL stack question: Why does pop() not throw an exception if the stack is empty? When designing a stack in C++, what should the pop() method (or front() method) return when the stack is empty? Which of the following design is

Make a delegate method in the replaceable custom class in Swift

So I have a custom class, and I've defined a delegate method for it. Here's a simplified example: protocol MyDelegate { func myDelegateMethod() } class Myclass (){ //other stuff func myDelegateMethod(){ //some operation } } And I would like to overri

How to write a line that has a method that returns a reference and implements it correctly?

I want to write a trait that has a method like foo(&self) -> &T and implement it for a concrete type rather than a reference. Here is what I've tried, but I can not get it to work: trait GetRef<'a> { fn get(&self) -> &'a u8; }

The scrolling method of the window flickers in IE

This may come as a huge surprise to some people but I am having an issue with the IE browser when I am using the $(window).scroll method. My goal: I would like to have the menu located on the left retain it's position until the scroll reaches > y val

How to update content based on user actions [like the wall of Facebook]

For my next application i would like to implement something that has a feature like the facebook wall but let me explain a bit. For those of you who used facebook you know that when somebody posts a message on your wall, and you are logged in to your

Protected access method of the child class in PHP

I can use at least two basic ways to access a protected class method from a child class: parent::myMethod(); $this->myMethod(); If I don't need to override it in the child class, in which case I would have to do this: function myMethod() { ... parent

C ++: Call another method for the default method argument

I'm playing with the default arguments for my Settings class in my project, so that I have a bit fewer methods declared. For instance, I have these methods declared: class Settings { // [..] int getCurrentUserID(); // returns current user id // you s

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK