Welcome Guest, Not a member yet? Register   Sign In
problem while returning views as data
#1

[eluser]Knight programmer[/eluser]
HYE,

as said in the title, in one of my views, i have a button and onclick event on it with some javascript .

The problem is when i retrieve the view as data and i display it , the onclick event is lost.

Any idea how to keep button events while returning views as data?

thank you for your help
#2

[eluser]Jondolar[/eluser]
I don't understand what you mean when you say the onclick event is lost. Are you using ajax to retrieve your data (view)? I think you need a callback function as ajax runs asynchronously.
#3

[eluser]louis w[/eluser]
I think it would be beneficial for us both if you included either sample code or even better an example site. Your description is somewhat ambiguous.
#4

[eluser]Dam1an[/eluser]
When you say "retreive the data", do you mean setting the 3rd param of load->view to true to retur it as a string?
If so, is there any reason you can't load the view instead of echoing this string?

But like louis said, we really need some code to get a proper idea of what you're on about
#5

[eluser]Knight programmer[/eluser]
Here is the situation:

controller.php
Code:
$partial_view = this-load-view("partial_view","",TRUE);
echo $partial_view;

partial_view.php
Code:
[removed]
function makeSmth()
{
   //code here
}
[removed]

<form id"partial_form">
input  type="button" onclick="makeSmth()"
</form>

main_view.php
Code:
[removed]
function treatment()
{
  var ajax;

  ajax.ondone= function(data){    
    
    document.getElementById("partial_view").setInnerFBML(data);
                     //setInnerFBML : function  given by Facebook plateform

     //HERE IS THE PROBLEM : the button of partial_view.php is displayed but the    
     // onclick=makeSmth()  doesn't work, that's the lost event that i spoke about.
     //What can i do for getting the onclick of the button of partial_view working in    
     //main_view ???
  }
   ajax.post("controller.php");
}
[removed]

<div id="partial_view">

</div>

Hope it's more clear .
#6

[eluser]Knight programmer[/eluser]
there is an alternative : JSON. I'll try it and give you feed back
#7

[eluser]steelaz[/eluser]
Where is your makeSmth() function located? To check onclick event try replacing onclick="makeSmth()" with something like onclick="alert('test')" to see if event fires.
#8

[eluser]louis w[/eluser]
At this point to me this looks like a front-end problem - not something related to Code Igniter.

Is it possible we can see a working example of this problem?
#9

[eluser]Knight programmer[/eluser]
Hye,

finnaly i figured out the problem,it was just something wrong with my javascript.

for the example, it's a facebook application. So when i complete the appli,i'll post the link.

Cheers




Theme © iAndrew 2016 - Forum software by © MyBB