I'm creating an inbox system for my website which allows basic communication between users. I'm fetching the results with jquery calling a webservice.
Then I'm using a jquery template engine to render the results to the screen. So far this all works good. but now I want to add some click functions on certain parts of inbox messages. For example I want the title of the message to be clickable so it will expand/collapse the fulltext which is hidden in a div beneath it.
But I can't seem to use the jquery selectors on this dynamic json result. It works when I put the function in the href tag itself but I don't really want to. I also tried adding the function after the success function but no luck either. Is it possible at all to use selectors with a template engine?
I hope I made myself clear otherwise feel free to ask more information. Thank you very much
Kind regards,
Mark
Have you tried jquery .live option? http://api.jquery.com/live/
I'm sorry, you'll see it happens all the time, when something goes wrong and I ask a question the minute after it it solves itselves. It is indeed possible to use the jquery selector on dynamic elements. Just make sure u put it after the template processing and in the ajax success function.
Thanks.
Are you trying to select the json that is returned from the webservice or are you trying to use the jquery selector to find an element that you added previously on to the page?
Related
Hi I am currently trying to follow this guide:
https://ribbonworkbench.uservoice.com/knowledgebase/articles/132235-create-a-workflow-short-cut-ribbon-button-no-code
So that I can create a button on the ribbon in CRM to start a workflow. The idea being that the user will fill in part of the form and then request approval.
However I have ran into an issue which is that at one point I have to define the library for the command actions to use and the guide state that we must use the "/_static/_common/scripts/RibbonActions.js" and the "/_static/_forms/form.js" library.
However not having done this before I have no idea how to include the library in the solution, so nothing appears on the library selection screen. I have tried searching how to complete this step but to no avail. Any help would be greatly appreciated.
Thank you.
What I understood is that you are trying to call a workflow from javascript on click of a ribbon button. If you have any reference javascript assembly then both of them should be referred for the javascript method to work as expected.
Lets assume we have two different javascripts files like reference.js and actual.js And the button is supposed to call a method button_click from actual.js. In such a case we will be adding two commands as follows:
Library:reference.js and FunctionName:isNaN
Library:actual.js and FunctionName:button_click
This way the reference javascript also will be loaded and the method should be working properly. Hope I was able to address your query. Let me know if you have any questions or still the problem persists.
There is a possibility to enter plain text to library field instead of choosing from a selector.
With alfresco advanced search form I would like to perform search by ajax and display the list of search results in the same page (without reloading the page).
Is it possible?
Is there a recommended way to do it?
Thank you in advance
So if I understand you clearly you don't want the page to reload.
Sure that's possible!
Do you start by hacking into the advanced search form or do you create a new page just for this is maybe the first question.
You can do it either way. Probably the latter is easier to maintain and less hacking and you can use a client-site Library of your preference.
If you want to keep the default form you just need to change the following files
advsearch.js, the client-side YUI file which gets run on the form and does the submit
/alfresco/site-webscripts/org/alfresco/components/search/advsearch.get.html.ftl, the html file which has all the div's etc. defined.
So change the client-side library to do the search directly to the repo, take a look at search.js and use the method.
Then define in your template the search results area from search.get.html.ftl.
So basically you're merging these 2 components into 1 big one.
i'm not sure how to call that. i'm looking for some samples guiding me how to implement a automatic page extend. i'm mean something like the friends list on facebook. first only a few friends are loaded. after you scroll down, some others get loaded.
thx in advance
The solution to your problem relies more on AJAX then anything else.
I suggest using jQuery Ajax, and here is a nice article that will get you started with calling ASP.NET web services via client side script.
enter link description here
If you don't have experience using ajax this will probably be a lot for you to grasp. Especially if you're going to dive in with a feature like you described above.
Edit: It may be more practical to use a plugin to achieve this:
scrolling jQuery plugin
Is there any other alternative of usercontrol other than webpart and iframe, Which i can use in my asp.net application.
thanks in advance.
Don't know what you are trying to achieve but at the top of my head I can say you can use an update panel to act as a type of iframe to load another page inside your page.
User control is already as abstract as possible: it's final and ultimate goal is to send something to the browser, based on parameters you give it from the server side. Label has Text property that once set, send <span> tag to the browser with that given text. Panel has collection of children that when set are sent to the browser wrapped in <div> element. Etc Etc..
So the direct answer is: no, no alternative.
However, based on your comment, there might be a way to improve the performance.. what control you currently have? How user can customize them? If you can explain better the scenario and post some relevant code it would be great.
Considering your comment on the question, Using usercontrols along with placeholders and some jQuery plugins OR simply web parts controls as containers is fine.
No need to change it unless you have a problem with it. Then we might discuss other options like Custom Server controls etc.. but those also have their issues, etc.. so it's always a balance.
If you have no problem and want to check whether this is the right thing that you do or something else, then I think the answer is, yeah. Unless you have specific issues, this way seems OK to go.
Walter Rumsby provided a great answer to Where to place JavaScript in an HTML file. He references the work done by the Yahoo Exceptional Performance team and their recommendation to place scripts at the bottom of the page. Which is a hard and fast rule that I've been following for quite sometime now. In the same thread Levi Rosol pointed out "the best place for it [JavaScript] is just before you need it an no sooner." That is the predicament that I now find myself in.
I've added my reference to jQuery at the end of my page but have run into an issue with how to structure a user control that I'd like to add client side functionality to. Specifically, I am having a hard time working out the best way to accommodate dependencies. The user control has a span tag containing a numeric value that I'd like to update based on the number of check boxes the user has checked in the user control. I am using jQuery to find the span tag and update its text property.
Unfortunately, unless my reference to jQuery appears prior to the user control I receive JavaScript errors. This makes sense because the control is referencing functions that have not yet been added. I can think of several solutions to the issue but am looking for a best practice option.
Placing a reference to the jQuery library inside of the user control.
Downside: if the user control was placed into a repeater multiple references to the jQuery library would be made.
Put no JavaScript in the user control and write all code to update the span tag for the user control in the containing page.
Downside: I'd end up with the same code in multiple places creating a potential maintenance nightmare.
Place the jQuery reference in the head section of the page.
Downside: I've violated the recommendation to place scripts at the bottom of the page and have created an unusable user control if the page does not include a reference to jQuery.
Those are the options and downsides I came up with when thinking about solutions to this problem. I am certainly open to suggestions for better solutions and barring none looking for a recommendation of which of the three I should choose.
There's a Google project that aims to solve these pains you may want to look at called Jingo:
http://code.google.com/p/jingo/
Another solution I'd recommend is a loader like YUI Loader Utility.
http://developer.yahoo.com/yui/yuiloader/
It will allow you to manage dependencies etc. and it's not just useful when you're using their UI components. It can be used for anything; just look at the docs around addModule.
If you're using ASP.NET the ScriptManager is another good solution.
Another option would be to dynamically generate the script reference by registering a startup script from your usercontrol that wrote a script reference to the document head.
The javascript function could check for an existing jQuery reference, and if none was found, write the reference out. This would solve the multiple references. A basic example was discussed in this thread.
The simplest solution to this I've found is to use a helper to accumulate Javascript fragments to be included at the page body while rendering other page elements. Then, you can include jQuery first, followed by any deferred literal Javascript fragments.
It does require maintaining some extra state during page generation, which can complicate your rendering pipeline just a bit. However, it allows you to get deferred Javascript inclusion, without requiring complex DOM manipulation after the page is loaded to pick out any existing references to jQuery.