locked
Tutorial to use core.js for custom ribbon control RRS feed

  • Question

  • Hi,
    I implemented some custom ribbon controls that work completely same as default server ribbon. For example, "Check In", "Check Out", "Delete"...
    Now I write new code according to core.js, but it is better that I can reuse methods in core.js. I tried, but this makes me confused.
    Is there any tutorials or blogs to learn how to reuse methods in core.js?
    Help greatly appreciated.
    Regards,
    Thursday, September 22, 2011 1:10 AM

Answers

  • You should not call function from Core.js directly. Rather create a custom ribbon control and then use JavaScript Object Model to perform your operation. You can also create a web service and call that from JavaScript.

    Thanks

    • Proposed as answer by Anupam Ranku Friday, September 23, 2011 4:32 AM
    • Marked as answer by Zizhuoye Chen Thursday, September 29, 2011 2:59 PM
    Thursday, September 22, 2011 5:54 AM
  • Oh then you should check out the SP.JS SP.Ribbon.js ... 

    the best way to find out such things is to use IE toolbar or google chrome element inspector to see what javascipt function is applied on the element and then find it in the js files in 14 folder... mostly its SP.js Core.js or Init.js

    that could be one way of going about it


    "T" | community.zevenseas.com/Blogs/Tanmay/default.aspx
    • Marked as answer by Zizhuoye Chen Thursday, September 29, 2011 2:59 PM
    Thursday, September 22, 2011 2:30 PM

All replies

  • You should not call function from Core.js directly. Rather create a custom ribbon control and then use JavaScript Object Model to perform your operation. You can also create a web service and call that from JavaScript.

    Thanks

    • Proposed as answer by Anupam Ranku Friday, September 23, 2011 4:32 AM
    • Marked as answer by Zizhuoye Chen Thursday, September 29, 2011 2:59 PM
    Thursday, September 22, 2011 5:54 AM
  • Hi, Anupam

    Thank you for your reply. According your suggestion, I use JavaScript Object Model to perform my control commands.

     

    Now I have another question.

    I want to know how MS implement Commands used in Server Ribbon.

    Where can I find it ?

     

    Regards,

    Thursday, September 22, 2011 9:18 AM
  • Thursday, September 22, 2011 9:24 AM
  • Hi, Tanmay

    Thank you for your reply, but I think my explanation is not enough.

    What I want to know is how "MS" implement their command, is not how to make custom ribbon or how to perform control's command by Declarative Customization or Page Component.

     

     

    Thursday, September 22, 2011 10:09 AM
  • oh ok.. well if you want to re use the code from core. js... you create a copy of the function in you custom js file and give them different names... then call these names from your ribbon button... add your js file is a part of the master page.. so when your button is clicked your custom function is called.... is that what you are looking for?


    "T" | community.zevenseas.com/Blogs/Tanmay/default.aspx
    Thursday, September 22, 2011 10:13 AM
  • Thank you for your reply again, Tanmay.

    I have already given up to use codes from core.js, because that way is unusual and I use javascript client object model to implement my command.

    Why I want to know codes used to implement default ribbon controls (like 'Delete', 'Check Out', etc) is just for studying.

    These codes may give me many useful suggestions for performing my commands, I think.

     

    Thursday, September 22, 2011 2:17 PM
  • Oh then you should check out the SP.JS SP.Ribbon.js ... 

    the best way to find out such things is to use IE toolbar or google chrome element inspector to see what javascipt function is applied on the element and then find it in the js files in 14 folder... mostly its SP.js Core.js or Init.js

    that could be one way of going about it


    "T" | community.zevenseas.com/Blogs/Tanmay/default.aspx
    • Marked as answer by Zizhuoye Chen Thursday, September 29, 2011 2:59 PM
    Thursday, September 22, 2011 2:30 PM
  • Hi,

    Not quite sure what you meant. If you deploy your solution or writing JS in SharePoint page, you already have access to Client Object Model e.g. you can do

    var clientContext = new SP.ClientContext(siteUrl) 

    See the sample code

    And when you are doing clientContext.executeQueryAsync() it fetch data from server.

    However, in several cases I have called webservice or opened application/content pages to perform multiple tasks at once; that is another option.

    Thanks

    Anupam Ranku
    http://mydevdiary.blogspot.com/ 

    Friday, September 23, 2011 4:32 AM
  • Thank you, Tanmay. Your answer is just what I want.

    I will try to use IE toolbar to check them.

     

    Hi, Anupam. Thank you for your reply again.

    I'm interested in your method to perform mutiple tasks at once.

    Does this method mean that user clicks a button, then the command related to the button calls webservice (e.g. .aspx page without screen transition, and when the tasks are done, a notification will show up in user screen?

    Sunday, September 25, 2011 1:40 PM