es131245 Posted March 7, 2014 Share Posted March 7, 2014 Usual function are easly edited by var script=$(document).ready;$(document).ready(function(){script; alert('document ready!');}); But how to edit functions in an object? var class={one:function(){alert('1');}, two:function(){alert('2');}} Link to comment Share on other sites More sharing options...
Ingolme Posted March 7, 2014 Share Posted March 7, 2014 What do you mean "edit"? Both of your examples do different things. Link to comment Share on other sites More sharing options...
es131245 Posted March 7, 2014 Author Share Posted March 7, 2014 I need to add some code in front of existing js function class.authorization(). Link to comment Share on other sites More sharing options...
justsomeguy Posted March 7, 2014 Share Posted March 7, 2014 You are being very vague. None of us know what "class.authorization" is, you haven't showed that. If you need to add code in front of other code, then why can't you just type the code there? What's the problem? Link to comment Share on other sites More sharing options...
es131245 Posted March 7, 2014 Author Share Posted March 7, 2014 var CODE = { auth: function () {//code }} How can i "prepend" some code at CODE.auth? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 7, 2014 Share Posted March 7, 2014 You just write the code in, with your text editor, like you write any other code.If you are trying to programmatically change the CODE object, then you can just define a new function like this: CODE.newfunction = function() { // some other function}If you are trying to programmatically change the auth function, you have to overwrite the function with a new one, which means you need to copy the code from auth and add your code to replace the function.CODE.auth = function() { // add the new code // paste the current code} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now